Class: Toggly::EntityContext
- Inherits:
-
Struct
- Object
- Struct
- Toggly::EntityContext
- Defined in:
- lib/toggly/entity_context.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#key ⇒ Object
Returns the value of attribute key.
-
#kind ⇒ Object
Returns the value of attribute kind.
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes
9 10 11 |
# File 'lib/toggly/entity_context.rb', line 9 def attributes @attributes end |
#key ⇒ Object
Returns the value of attribute key
9 10 11 |
# File 'lib/toggly/entity_context.rb', line 9 def key @key end |
#kind ⇒ Object
Returns the value of attribute kind
9 10 11 |
# File 'lib/toggly/entity_context.rb', line 9 def kind @kind end |
Instance Method Details
#attribute(name) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/toggly/entity_context.rb', line 10 def attribute(name) return nil unless attributes.is_a?(Hash) return attributes[name] if attributes.key?(name) return attributes[name.to_s] if attributes.key?(name.to_s) attributes.each { |k, v| return v if k.to_s.casecmp?(name.to_s) } nil end |
#attribute?(name) ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/toggly/entity_context.rb', line 20 def attribute?(name) return false unless attributes.is_a?(Hash) attributes.key?(name) || attributes.key?(name.to_s) || attributes.keys.any? { |k| k.to_s.casecmp?(name.to_s) } end |