Module: Kiita::Model::ClassMethods

Defined in:
lib/kiita/model.rb

Instance Method Summary collapse

Instance Method Details

#define_attributes(attrs, getter_method) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kiita/model.rb', line 21

def define_attributes(attrs, getter_method)
  attrs.each do |attribute_name|
    class_eval <<-RUBY
      def #{attribute_name}
        @#{attribute_name} ||= raw_attributes["#{attribute_name}"]
      end
    RUBY
  end

  define_method(:raw_data, &getter_method)
end