Module: Zen::Query::Attributes::ClassMethods
- Defined in:
- lib/zen/query/attributes.rb
Instance Method Summary collapse
- #attribute_methods ⇒ Object
- #attributes(*attrs) ⇒ Object
- #attributes_list ⇒ Object
- #inherited(query_class) ⇒ Object
Instance Method Details
#attribute_methods ⇒ Object
14 15 16 |
# File 'lib/zen/query/attributes.rb', line 14 def attribute_methods const_get(:AttributeMethods) end |
#attributes(*attrs) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/zen/query/attributes.rb', line 18 def attributes(*attrs) attributes_list.concat(attrs) attrs.each do |name| attribute_methods.send(:define_method, name) { @attributes[name] } end end |
#attributes_list ⇒ Object
26 27 28 |
# File 'lib/zen/query/attributes.rb', line 26 def attributes_list @attributes_list ||= [] end |
#inherited(query_class) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/zen/query/attributes.rb', line 7 def inherited(query_class) query_class.const_set(:AttributeMethods, Module.new) query_class.send(:include, query_class::AttributeMethods) query_class.attributes_list.replace(attributes_list.dup) super end |