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
71 72 73 74 75 |
# File 'lib/apple-news/properties.rb', line 71 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
86 87 88 |
# File 'lib/apple-news/properties.rb', line 86 def optional_properties(*args) args.each { |arg| optional_property(arg) } end |
#optional_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
90 91 92 93 |
# File 'lib/apple-news/properties.rb', line 90 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
99 100 101 |
# File 'lib/apple-news/properties.rb', line 99 def properties _required_property_map.merge(_optional_property_map) end |
#property_inflection(name, inflection) ⇒ Object
95 96 97 |
# File 'lib/apple-news/properties.rb', line 95 def property_inflection(name, inflection) _property_inflection[name] = inflection end |
#required_properties(*args) ⇒ Object
77 78 79 |
# File 'lib/apple-news/properties.rb', line 77 def required_properties(*args) args.each { |arg| required_property(arg) } end |
#required_property(name, default = nil, klass = nil, init_method = :new) ⇒ Object
81 82 83 84 |
# File 'lib/apple-news/properties.rb', line 81 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 |