Class: EPlat::AttributeInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/e_plat/resource/attribute_interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, keys:) ⇒ AttributeInterface

Returns a new instance of AttributeInterface.



5
6
7
8
# File 'lib/e_plat/resource/attribute_interface.rb', line 5

def initialize(parent, keys:)
  @parent, @keys = parent, keys
  add_convenience_methods
end

Instance Attribute Details

#keysObject

Returns the value of attribute keys.



3
4
5
# File 'lib/e_plat/resource/attribute_interface.rb', line 3

def keys
  @keys
end

#parentObject

Returns the value of attribute parent.



3
4
5
# File 'lib/e_plat/resource/attribute_interface.rb', line 3

def parent
  @parent
end

Instance Method Details

#entriesObject



14
15
16
# File 'lib/e_plat/resource/attribute_interface.rb', line 14

def entries
  keys.map{|k| {k => parent.send(k)} }.inject(&:merge)
end

#exclude?(value) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/e_plat/resource/attribute_interface.rb', line 30

def exclude?(value)
  !include? value
end

#include?(value) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/e_plat/resource/attribute_interface.rb', line 26

def include?(value)
  entries.include? value
end

#inspectObject



10
11
12
# File 'lib/e_plat/resource/attribute_interface.rb', line 10

def inspect
  "#<#{self.class} keys=#{keys.inspect}>"
end