Class: Super::Schema::Fields
- Inherits:
-
Object
- Object
- Super::Schema::Fields
- Includes:
- Enumerable
- Defined in:
- lib/super/schema.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Fields
constructor
A new instance of Fields.
- #keys ⇒ Object
- #nested ⇒ Object
- #replace(other) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Fields
Returns a new instance of Fields.
31 32 33 |
# File 'lib/super/schema.rb', line 31 def initialize @backing = {} end |
Instance Method Details
#[](key) ⇒ Object
35 36 37 |
# File 'lib/super/schema.rb', line 35 def [](key) @backing[key] end |
#[]=(key, value) ⇒ Object
39 40 41 |
# File 'lib/super/schema.rb', line 39 def []=(key, value) @backing[key] = value end |
#each ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/super/schema.rb', line 47 def each if block_given? return @backing.each(&Proc.new) end enum_for(:each) end |
#keys ⇒ Object
43 44 45 |
# File 'lib/super/schema.rb', line 43 def keys @backing.keys end |
#nested ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/super/schema.rb', line 63 def nested outside = @backing inside = {} @backing = inside yield @backing = outside inside end |
#replace(other) ⇒ Object
55 56 57 |
# File 'lib/super/schema.rb', line 55 def replace(other) @backing = other end |
#to_h ⇒ Object
59 60 61 |
# File 'lib/super/schema.rb', line 59 def to_h @backing end |