Class: Ymodel::Schema
- Inherits:
-
Object
- Object
- Ymodel::Schema
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/ymodel/schema.rb
Overview
Represents a schema of all keys found in the source.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #<<(attribute) ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(source, *keys) ⇒ Schema
constructor
A new instance of Schema.
Constructor Details
#initialize(source, *keys) ⇒ Schema
Returns a new instance of Schema.
14 15 16 17 18 |
# File 'lib/ymodel/schema.rb', line 14 def initialize(source, *keys) @attributes = source.flat_map(&:keys) .map(&:to_sym) .to_set + keys end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/ymodel/schema.rb', line 10 def attributes @attributes end |
Instance Method Details
#<<(attribute) ⇒ Object
24 25 26 |
# File 'lib/ymodel/schema.rb', line 24 def <<(attribute) @attributes << attribute.to_sym end |
#include?(key) ⇒ Boolean
20 21 22 |
# File 'lib/ymodel/schema.rb', line 20 def include?(key) attributes.include?(key.to_sym) end |