Sha256: e2cbe6b18a7e70bd6191711804bb6cbcecf1f769fc119d3c7b51cacaea29fbec

Contents?: true

Size: 523 Bytes

Versions: 23

Compression:

Stored size: 523 Bytes

Contents

module G5Updatable::FirstClassProperties
  extend ActiveSupport::Concern

  included do
    after_initialize :define_methods_for_properties
  end

  def properties=(hash)
    write_attribute("properties", hash)
    define_methods_for_properties
  end

protected

  def define_methods_for_properties
    return unless properties.present?

    properties.each do |key, value|
      next if respond_to?(key)
      define_singleton_method(key) do
        properties[key.to_s] if properties.present?
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
g5_updatable-0.20.3.pre.1 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.10.3 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.10.2 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.10.1 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.10.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.9.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.8.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.7.2 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.7.1 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.7.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.6.1 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.6.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.5.1 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.5.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.4.3 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.4.2 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.4.1 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.4.0 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.3.5 app/concerns/g5_updatable/first_class_properties.rb
g5_updatable-0.3.4 app/concerns/g5_updatable/first_class_properties.rb