Class: Super::Schema::Fields

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/super/schema.rb

Instance Method Summary collapse

Constructor Details

#initializeFields

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

#eachObject



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

#keysObject



43
44
45
# File 'lib/super/schema.rb', line 43

def keys
  @backing.keys
end

#nestedObject



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_hObject



59
60
61
# File 'lib/super/schema.rb', line 59

def to_h
  @backing
end