Module: PDC::Resource::Attributes::ClassMethods
- Defined in:
- lib/pdc/resource/attributes.rb
Overview
:nodoc:
Instance Method Summary collapse
- #attribute(name, metadata) ⇒ Object
- #attribute_parser(name) ⇒ Object
-
#attributes(*names) ⇒ Object
define attributes on Model using attributes :attribute_name, attribute_name_2 …
- #attributes_metadata ⇒ Object
Instance Method Details
#attribute(name, metadata) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/pdc/resource/attributes.rb', line 21 def attribute(name, ) attr_exists = .key?(name) [name] ||= [name].merge!() define_methods_in_container(name) unless attr_exists end |
#attribute_parser(name) ⇒ Object
33 34 35 36 37 |
# File 'lib/pdc/resource/attributes.rb', line 33 def attribute_parser(name) # do not add to attributes of the class if not already present = .fetch(name, ) [:parser] end |
#attributes(*names) ⇒ Object
define attributes on Model using attributes :attribute_name, attribute_name_2 …
15 16 17 18 19 |
# File 'lib/pdc/resource/attributes.rb', line 15 def attributes(*names) return .keys if names.empty? names.each { |n| [n] ||= } define_methods_in_container(names) end |
#attributes_metadata ⇒ Object
29 30 31 |
# File 'lib/pdc/resource/attributes.rb', line 29 def @attributes_metadata ||= HashWithIndifferentAccess.new(primary_key => ) end |