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
79 80 81 82 83 |
# File 'lib/apple-news/properties.rb', line 79 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
94 95 96 |
# File 'lib/apple-news/properties.rb', line 94 def optional_properties(*args) args.each { |arg| optional_property(arg) } end |
#optional_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
98 99 100 101 |
# File 'lib/apple-news/properties.rb', line 98 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
107 108 109 |
# File 'lib/apple-news/properties.rb', line 107 def properties _required_property_map.merge(_optional_property_map) end |
#property_inflection(name, inflection) ⇒ Object
103 104 105 |
# File 'lib/apple-news/properties.rb', line 103 def property_inflection(name, inflection) _property_inflection[name] = inflection end |
#required_properties(*args) ⇒ Object
85 86 87 |
# File 'lib/apple-news/properties.rb', line 85 def required_properties(*args) args.each { |arg| required_property(arg) } end |
#required_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
89 90 91 92 |
# File 'lib/apple-news/properties.rb', line 89 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 |