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

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

#attributeObject



14
15
16
# File 'lib/knife-attribute/helpers.rb', line 14

def attribute
  @attribute ||= @name_args[1]
end

#attribute_type_mapObject



34
35
36
# File 'lib/knife-attribute/helpers.rb', line 34

def attribute_type_map
  self.class.attribute_type_map
end

#default_attribute_typeObject



38
39
40
# File 'lib/knife-attribute/helpers.rb', line 38

def default_attribute_type
  self.class.default_attribute_type
end

#entityObject



26
27
28
# File 'lib/knife-attribute/helpers.rb', line 26

def entity
  @entity = send(entity_type)
end

#entity_nameObject



22
23
24
# File 'lib/knife-attribute/helpers.rb', line 22

def entity_name
  @entity_name ||= @name_args[0]
end

#entity_typeObject



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_configObject



42
43
44
# File 'lib/knife-attribute/helpers.rb', line 42

def mapped_config
  @mapped_config ||= config[:attribute_type] == 'normal' ? {} : {all_attributes: true}
end

#valueObject



18
19
20
# File 'lib/knife-attribute/helpers.rb', line 18

def value
  @value ||= @name_args[2]
end