Sha256: 121110b72d5e1fd3b4b5cf3605e03c2fef515a0484da884c3d69b542da74b62a

Contents?: true

Size: 497 Bytes

Versions: 8

Compression:

Stored size: 497 Bytes

Contents

module PhModel
  module Concerns
    module AttributeOfArrayTypeInitialization
      extend ActiveSupport::Concern

      included do |other|
        other.after_initialize :initialize_array_type_attributes
      end

      def initialize_array_type_attributes
        self.class.attributes.each do |attribute_name, info|
          if info[:type].kind_of?(Array)
            send("#{attribute_name}=", []) unless send(attribute_name).present?
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ph_model-1.2.0 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.1.3 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.1.2 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.1.1 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.1.0 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.0.2 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.0.1 lib/ph_model/concerns/attribute_of_array_type_initialization.rb
ph_model-1.0.0 lib/ph_model/concerns/attribute_of_array_type_initialization.rb