Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use the rails 7.1+ serialize interface #23253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/chargeback_rate_detail_measure.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ChargebackRateDetailMeasure < ApplicationRecord
serialize :units, Array
serialize :units_display, Array
serialize :units, :type => Array
serialize :units_display, :type => Array
validates :name, :presence => true, :length => {:maximum => 100}
validates :step, :presence => true, :numericality => {:greater_than => 0}
validates :units, :presence => true, :length => {:minimum => 2}
Expand Down
4 changes: 2 additions & 2 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class ContainerImage < ApplicationRecord
has_many :metrics, :as => :resource, :dependent => :nullify, :inverse_of => :resource
has_many :vim_performance_states, :as => :resource, :dependent => :nullify, :inverse_of => :resource

serialize :exposed_ports, Hash
serialize :environment_variables, Hash
serialize :exposed_ports, :type => Hash
serialize :environment_variables, :type => Hash

virtual_column :display_registry, :type => :string
virtual_total :total_containers, :containers
Expand Down
4 changes: 2 additions & 2 deletions app/models/container_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ContainerTemplate < ApplicationRecord
:as => :resource,
:inverse_of => :resource

serialize :objects, Array
serialize :object_labels, Hash
serialize :objects, :type => Array
serialize :object_labels, :type => Hash

acts_as_miq_taggable

Expand Down
2 changes: 1 addition & 1 deletion app/models/custom_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CustomButton < ApplicationRecord
order(Arel.sql(order))
}

serialize :options, Hash
serialize :options, :type => Hash
serialize :visibility_expression
serialize :enablement_expression
serialize :visibility
Expand Down
8 changes: 4 additions & 4 deletions app/models/dialog_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class DialogField < ApplicationRecord
default_value_for :load_values_on_init, true

serialize :values
serialize :values_method_options, Hash
serialize :display_method_options, Hash
serialize :required_method_options, Hash
serialize :options, Hash
serialize :values_method_options, :type => Hash
serialize :display_method_options, :type => Hash
serialize :required_method_options, :type => Hash
serialize :options, :type => Hash

after_initialize :default_resource_action

Expand Down
2 changes: 1 addition & 1 deletion app/models/generic_object_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GenericObjectDefinition < ApplicationRecord
REG_METHOD_NAME = /\A[a-z][a-zA-Z_0-9]*[!?]?\z/
ALLOWED_ASSOCIATION_TYPES = (MiqReport.reportable_models + %w[GenericObject]).freeze

serialize :properties, Hash
serialize :properties, :type => Hash

include CustomActionsMixin

Expand Down
2 changes: 1 addition & 1 deletion app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Host < ApplicationRecord
# Physical server reference
belongs_to :physical_server, :inverse_of => :host

serialize :settings, Hash
serialize :settings, :type => Hash

deprecate_attribute :address, :hostname, :type => :string
alias_attribute :state, :power_state
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MiqAction < ApplicationRecord

has_many :miq_policy_contents

serialize :options, Hash
serialize :options, :type => Hash

# Add a instance method to store the sequence and synchronous values from the policy contents
attr_accessor :sequence, :synchronous, :reserved
Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_ae_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MiqAeMethod < ApplicationRecord
# switch back to validates :exclusion once rails 6.1 issue is fixed
# https://github.com/rails/rails/issues/41051
validate :embedded_methods_not_nil
serialize :options, Hash
serialize :options, :type => Hash
before_validation :set_relative_path

belongs_to :domain, :class_name => "MiqAeDomain", :inverse_of => false
Expand Down
4 changes: 2 additions & 2 deletions app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def self.lower_priority?(p1, p2)

TIMEOUT = 10.minutes

serialize :args, Array
serialize :miq_callback, Hash
serialize :args, :type => Array
serialize :miq_callback, :type => Hash

validate :validate_zone_name

Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MiqRequest < ApplicationRecord

alias_attribute :state, :request_state

serialize :options, Hash
serialize :options, :type => Hash

default_value_for(:message) { |r| "#{r.class::TASK_DESCRIPTION} - Request Created" }
default_value_for :options, {}
Expand Down
4 changes: 2 additions & 2 deletions app/models/miq_request_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class MiqRequestTask < ApplicationRecord
belongs_to :miq_request_task
belongs_to :tenant

serialize :phase_context, Hash
serialize :options, Hash
serialize :phase_context, :type => Hash
serialize :options, :type => Hash

default_value_for :phase_context, {}
default_value_for :options, {}
Expand Down
4 changes: 2 additions & 2 deletions app/models/mixins/service_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ServiceMixin
has_many :service_resources, -> { order("group_idx ASC") }, :dependent => :destroy
has_many :resource_actions, :as => :resource, :dependent => :destroy

serialize :options, Hash
serialize :options, :type => Hash

include UuidMixin
acts_as_miq_taggable
Expand Down Expand Up @@ -104,7 +104,7 @@ def parent_services(svc = self)
private

def enforce_single_service_parent(resource)
if resource.try(:enforce_single_service_parent?) == true && resource.service
if resource.try(:enforce_single_service_parent?) == true && resource.class.reflections[:service] && resource.service
raise MiqException::Error, _("<%{class_name}> <%{id}>:<%{name}> is already connected to a service.") %
{:class_name => resource.class.name, :id => resource.id, :name => resource.name}
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Notification < ApplicationRecord

before_save :backup_subject_name

serialize :options, Hash
serialize :options, :type => Hash
default_value_for(:options) { {} }

validate :complete_bindings
Expand Down
2 changes: 1 addition & 1 deletion app/models/persistent_volume.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class PersistentVolume < ContainerVolume
acts_as_miq_taggable
include NewWithTypeStiMixin
serialize :capacity, Hash
serialize :capacity, :type => Hash
delegate :name, :to => :parent, :prefix => true, :allow_nil => true
has_many :container_volumes, -> { where(:type => 'ContainerVolume') }, :through => :persistent_volume_claim
has_many :parents, -> { distinct }, :through => :container_volumes, :source_type => 'ContainerGroup'
Expand Down
6 changes: 3 additions & 3 deletions app/models/persistent_volume_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ class PersistentVolumeClaim < ApplicationRecord
belongs_to :ext_management_system, :foreign_key => "ems_id"
belongs_to :container_project
has_many :container_volumes
serialize :capacity, Hash
serialize :requests, Hash
serialize :limits, Hash
serialize :capacity, :type => Hash
serialize :requests, :type => Hash
serialize :limits, :type => Hash

virtual_column :storage_capacity, :type => :integer

Expand Down
2 changes: 1 addition & 1 deletion app/models/resource_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ResourceAction < ApplicationRecord
belongs_to :configuration_script_payload, :foreign_key => :configuration_script_id
belongs_to :dialog

serialize :ae_attributes, Hash
serialize :ae_attributes, :type => Hash

validate :ensure_configuration_script_or_automate

Expand Down
2 changes: 1 addition & 1 deletion app/models/snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Snapshot < ApplicationRecord

belongs_to :vm_or_template

serialize :disks, Array
serialize :disks, :type => Array

after_create :after_create_callback

Expand Down
2 changes: 1 addition & 1 deletion app/models/system_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SystemService < ApplicationRecord
belongs_to :host_service_group
has_one :cloud_service, :dependent => :nullify

serialize :dependencies, Hash
serialize :dependencies, :type => Hash

scope :running_systemd_services, -> { where(:systemd_active => 'active', :systemd_sub => 'running') }
scope :failed_systemd_services, -> { where(:systemd_active => 'failed').or(where(:systemd_sub => 'failed')) }
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class User < ApplicationRecord
# with the class method of the same name (User.authenticate)
alias_method :authenticate_bcrypt, :authenticate

serialize :settings, Hash # Implement settings column as a hash
serialize :settings, :type => Hash # Implement settings column as a hash
default_value_for(:settings) { {} }

default_value_for :failed_login_attempts, 0
Expand Down
2 changes: 1 addition & 1 deletion app/models/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Zone < ApplicationRecord
validates_presence_of :name, :description
validates :name, :unique_within_region => true

serialize :settings, Hash
serialize :settings, :type => Hash

belongs_to :log_file_depot, :class_name => "FileDepot"

Expand Down
Loading