Module: Access::MuchMeta

Instance Method Summary collapse

Instance Method Details

#set_up_methods(values) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/access/much_meta.rb', line 4

def set_up_methods(values)
  self.class.class_eval do
    if Access.config.access_used_fields == 'true'
      attr_reader :used_fields
      values.keys.each do |key|
        define_method(key.to_sym) do
          @used_fields << key.to_sym
          instance_variable_get("@#{key.to_sym}")
        end
      end
    else
      attr_reader(*values.keys)
    end
  end
end

#set_values(values) ⇒ Object



20
21
22
23
24
# File 'lib/access/much_meta.rb', line 20

def set_values(values)
  values.each do |attribute_name, attribute_value|
    self.instance_variable_set("@#{attribute_name}", attribute_value)
  end
end