Class: Super::Schema::Fields
- Inherits:
-
Object
- Object
- Super::Schema::Fields
- Includes:
- Enumerable
- Defined in:
- lib/super/schema.rb
Overview
This class can be thought of as a Hash, where the keys usually refer to
the model's column name and the value refers to the column type. Note
though that this isn't always the case—different SchemaTypes
can do
whatever makes sense in their context
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ Fields
constructor
A new instance of Fields.
- #keys ⇒ Object
- #nested ⇒ Object
- #replace(other) ⇒ Object
- #to_h ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize ⇒ Fields
Returns a new instance of Fields.
17 18 19 |
# File 'lib/super/schema.rb', line 17 def initialize @backing = {} end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/super/schema.rb', line 21 def [](key) @backing[key] end |
#[]=(key, value) ⇒ Object
25 26 27 |
# File 'lib/super/schema.rb', line 25 def []=(key, value) @backing[key] = value end |
#each(&block) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/super/schema.rb', line 37 def each(&block) if block_given? return @backing.each(&block) end enum_for(:each) end |
#keys ⇒ Object
29 30 31 |
# File 'lib/super/schema.rb', line 29 def keys @backing.keys end |
#nested ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/super/schema.rb', line 53 def nested outside = @backing inside = {} @backing = inside yield return inside ensure @backing = outside inside end |
#replace(other) ⇒ Object
45 46 47 |
# File 'lib/super/schema.rb', line 45 def replace(other) @backing = other end |
#to_h ⇒ Object
49 50 51 |
# File 'lib/super/schema.rb', line 49 def to_h @backing end |
#values ⇒ Object
33 34 35 |
# File 'lib/super/schema.rb', line 33 def values @backing.values end |