Module: AppleNews::Properties::ClassMethods
- Defined in:
- lib/apple-news/properties.rb
Instance Method Summary collapse
- #inherited(base) ⇒ Object
- #optional_properties(*args) ⇒ Object
- #optional_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
- #properties ⇒ Object
- #property_inflection(name, inflection) ⇒ Object
- #required_properties(*args) ⇒ Object
- #required_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
Instance Method Details
#inherited(base) ⇒ Object
78 79 80 81 82 |
# File 'lib/apple-news/properties.rb', line 78 def inherited(base) super base._required_property_map = _required_property_map.dup base._optional_property_map = _optional_property_map.dup end |
#optional_properties(*args) ⇒ Object
93 94 95 |
# File 'lib/apple-news/properties.rb', line 93 def optional_properties(*args) args.each { |arg| optional_property(arg) } end |
#optional_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
97 98 99 100 |
# File 'lib/apple-news/properties.rb', line 97 def optional_property(name, default = nil, klass = nil, init_method = :new) _optional_property_map[name] = { default: default, klass: klass, init_method: init_method } attr_accessor name end |
#properties ⇒ Object
106 107 108 |
# File 'lib/apple-news/properties.rb', line 106 def properties _required_property_map.merge(_optional_property_map) end |
#property_inflection(name, inflection) ⇒ Object
102 103 104 |
# File 'lib/apple-news/properties.rb', line 102 def property_inflection(name, inflection) _property_inflection[name] = inflection end |
#required_properties(*args) ⇒ Object
84 85 86 |
# File 'lib/apple-news/properties.rb', line 84 def required_properties(*args) args.each { |arg| required_property(arg) } end |
#required_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
88 89 90 91 |
# File 'lib/apple-news/properties.rb', line 88 def required_property(name, default = nil, klass = nil, init_method = :new) _required_property_map[name] = { default: default, klass: klass, init_method: init_method } attr_accessor name end |