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(klass, keys:) ⇒ AttributeInterface

Returns a new instance of AttributeInterface.



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

def initialize(klass, keys:)
	@klass, @keys = klass, keys
	
	add_to_instance! if keys.present?
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

#klassObject

Returns the value of attribute klass.



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

def klass
  @klass
end

Instance Method Details

#entriesObject



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

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

#exclude?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

def exclude?(value)
	!include? value
end

#include?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#inspectObject



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

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