Module: Fixture::Hashable

Defined in:
lib/lax/source.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(hashable) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/lax/source.rb', line 52

def self.new(hashable)
  hash = hashable.to_hash
  klass = Struct.new(*hash.keys)
  klass.send :include, self, Fixture
  klass.new(*hash.values.map do |val|
    (Hash===val) ? new(val) : val
  end)
end

Instance Method Details

#merge(hashable) ⇒ Object



67
68
69
# File 'lib/lax/source.rb', line 67

def merge(hashable)
  Hashable.new to_hash.merge hashable
end

#to_hashObject



61
62
63
64
65
# File 'lib/lax/source.rb', line 61

def to_hash
  Hash[
    members.zip entries.map {|e| e.kind_of?(Hashable) ? e.to_hash : e }
  ]
end