Module: KnifeAttribute::Helpers
- Included in:
- Environment::Helpers, Node::Helpers, Role::Helpers
- Defined in:
- lib/knife-attribute/helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #attribute ⇒ Object
- #attribute_type_map ⇒ Object
- #default_attribute_type ⇒ Object
- #entity ⇒ Object
- #entity_name ⇒ Object
- #entity_type ⇒ Object
- #mapped_config ⇒ Object
- #value ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/knife-attribute/helpers.rb', line 3 def self.included(base) base.class_eval do def self.attribute_type_map fail NotImplementedError, "Missing `attribute_types` implementation for current object" end def self.default_attribute_type fail NotImplementedError, "Missing `default_attribute_type` implementation for current object" end end end |
Instance Method Details
#attribute ⇒ Object
14 15 16 |
# File 'lib/knife-attribute/helpers.rb', line 14 def attribute @attribute ||= @name_args[1] end |
#attribute_type_map ⇒ Object
34 35 36 |
# File 'lib/knife-attribute/helpers.rb', line 34 def attribute_type_map self.class.attribute_type_map end |
#default_attribute_type ⇒ Object
38 39 40 |
# File 'lib/knife-attribute/helpers.rb', line 38 def default_attribute_type self.class.default_attribute_type end |
#entity ⇒ Object
26 27 28 |
# File 'lib/knife-attribute/helpers.rb', line 26 def entity @entity = send(entity_type) end |
#entity_name ⇒ Object
22 23 24 |
# File 'lib/knife-attribute/helpers.rb', line 22 def entity_name @entity_name ||= @name_args[0] end |
#entity_type ⇒ Object
30 31 32 |
# File 'lib/knife-attribute/helpers.rb', line 30 def entity_type fail NotImplementedError, "Missing `entity_type` implementation for current object" end |
#mapped_config ⇒ Object
42 43 44 |
# File 'lib/knife-attribute/helpers.rb', line 42 def mapped_config @mapped_config ||= config[:attribute_type] == 'normal' ? {} : {all_attributes: true} end |
#value ⇒ Object
18 19 20 |
# File 'lib/knife-attribute/helpers.rb', line 18 def value @value ||= @name_args[2] end |