Class: Eco::API::Common::Loaders::Parser::RequiredAttrs
- Defined in:
- lib/eco/api/common/loaders/parser.rb
Overview
Helper class to scope what required attributes it depends on
Instance Attribute Summary collapse
-
#attr ⇒ Object
Returns the value of attribute attr.
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Instance Attribute Details
#attr ⇒ Object
Returns the value of attribute attr
7 8 9 |
# File 'lib/eco/api/common/loaders/parser.rb', line 7 def attr @attr end |
#attrs ⇒ Object
Returns the value of attribute attrs
7 8 9 |
# File 'lib/eco/api/common/loaders/parser.rb', line 7 def attrs @attrs end |
#type ⇒ Object
Returns the value of attribute type
7 8 9 |
# File 'lib/eco/api/common/loaders/parser.rb', line 7 def type @type end |
Instance Method Details
#active?(*input_attrs) ⇒ Boolean
8 9 10 |
# File 'lib/eco/api/common/loaders/parser.rb', line 8 def active?(*input_attrs) missing(*input_attrs).empty? end |
#dependant?(attr) ⇒ Boolean
12 13 14 |
# File 'lib/eco/api/common/loaders/parser.rb', line 12 def dependant?(attr) attrs.include?(attr) end |
#missing(*input_attrs) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/eco/api/common/loaders/parser.rb', line 16 def missing(*input_attrs) return [] if input_attrs.include?(attr) match = input_attrs & attrs miss = attrs - match return [] if miss.empty? return attrs if match.empty? return miss if type == :all [] end |