module K::Replace::DynamicAccessors

Public Instance Methods

create_accessors(attributes) click to toggle source
# File lib/k/replace/dynamic_accessors.rb, line 6
def create_accessors(attributes)
  @_dynamic_attributes = attributes.with_indifferent_access
  @_dynamic_attributes.each_with_index do |attribute, index|
    create_accessor attribute[0].to_s
  end
end

Private Instance Methods

create_accessor(name) click to toggle source
# File lib/k/replace/dynamic_accessors.rb, line 15
        def create_accessor(name)
          class_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{name}
              @_dynamic_attributes["#{name}"]
            end
          RUBY
        end