Class: Contracted::Json::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/contracted/json.rb

Instance Method Summary collapse

Constructor Details

#initialize(elements) ⇒ Object

Returns a new instance of Object.



14
15
16
17
# File 'lib/contracted/json.rb', line 14

def initialize elements
  @hash = elements.select {|e| e != Wildcard.instance }.inject({}) {|r, h| r.merge(h)}
  @include = elements.include? Wildcard.instance
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/contracted/json.rb', line 19

def == other
  if @include
    other.merge(@hash) == other
  else
    @hash == other
  end
end