Class: Pact::SomethingLike
- Inherits:
-
Object
- Object
- Pact::SomethingLike
show all
- Includes:
- SymbolizeKeys
- Defined in:
- lib/pact/something_like.rb
Overview
Specifies that the actual object should be considered a match if it includes the same keys, and the values of the keys are of the same class.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included, #symbolize_keys
Constructor Details
Returns a new instance of SomethingLike.
12
13
14
|
# File 'lib/pact/something_like.rb', line 12
def initialize contents
@contents = contents
end
|
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
10
11
12
|
# File 'lib/pact/something_like.rb', line 10
def contents
@contents
end
|
Class Method Details
.json_create(hash) ⇒ Object
31
32
33
|
# File 'lib/pact/something_like.rb', line 31
def self.json_create hash
new(symbolize_keys(hash)[:contents])
end
|
Instance Method Details
#==(other) ⇒ Object
39
40
41
|
# File 'lib/pact/something_like.rb', line 39
def == other
other.is_a?(SomethingLike) && other.contents == self.contents
end
|
#as_json(opts = {}) ⇒ Object
23
24
25
|
# File 'lib/pact/something_like.rb', line 23
def as_json opts = {}
to_hash
end
|
#eq(other) ⇒ Object
35
36
37
|
# File 'lib/pact/something_like.rb', line 35
def eq other
self == other
end
|
#generate ⇒ Object
43
44
45
|
# File 'lib/pact/something_like.rb', line 43
def generate
contents
end
|
#to_hash ⇒ Object
16
17
18
19
20
21
|
# File 'lib/pact/something_like.rb', line 16
def to_hash
{
:json_class => self.class.name,
:contents => contents
}
end
|
#to_json(opts = {}) ⇒ Object
27
28
29
|
# File 'lib/pact/something_like.rb', line 27
def to_json opts = {}
as_json.to_json opts
end
|