Class: Eco::API::Common::Loaders::Parser::RequiredAttrs
- Inherits:
-
Struct
- Object
- Struct
- 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
8 9 10 |
# File 'lib/eco/api/common/loaders/parser.rb', line 8 def attr @attr end |
#attrs ⇒ Object
Returns the value of attribute attrs
8 9 10 |
# File 'lib/eco/api/common/loaders/parser.rb', line 8 def attrs @attrs end |
#type ⇒ Object
Returns the value of attribute type
8 9 10 |
# File 'lib/eco/api/common/loaders/parser.rb', line 8 def type @type end |
Instance Method Details
#active?(*input_attrs) ⇒ Boolean
9 10 11 |
# File 'lib/eco/api/common/loaders/parser.rb', line 9 def active?(*input_attrs) missing(*input_attrs).empty? end |
#dependant?(attr) ⇒ Boolean
13 14 15 |
# File 'lib/eco/api/common/loaders/parser.rb', line 13 def dependant?(attr) attrs.include?(attr) end |
#missing(*input_attrs) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/eco/api/common/loaders/parser.rb', line 17 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 |