Module: PeppersGhost::Core
- Defined in:
- lib/peppers-ghost/core.rb
Instance Method Summary collapse
- #match_resource_type(json_resource, resource, attributes, strict = false) ⇒ Object
- #match_structure(json_resource, attributes, count = nil, method = nil) ⇒ Object
- #match_values(json_resource, resource, attributes, strict = false) ⇒ Object
Instance Method Details
#match_resource_type(json_resource, resource, attributes, strict = false) ⇒ Object
2 3 4 5 |
# File 'lib/peppers-ghost/core.rb', line 2 def match_resource_type(json_resource, resource, attributes, strict = false) match_structure json_resource, attributes match_values json_resource, resource, attributes, strict end |
#match_structure(json_resource, attributes, count = nil, method = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/peppers-ghost/core.rb', line 7 def match_structure(json_resource, attributes, count = nil, method = nil) method ||= :resource expect(json_resource).to_not be_nil if json_resource.is_a?(Array) expect(json_resource).to have(count).method_missing(method) if count match_single_structure json_resource, attributes, count else expect(json_resource.keys).to match_array attributes.map(&:to_s) end end |
#match_values(json_resource, resource, attributes, strict = false) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/peppers-ghost/core.rb', line 19 def match_values(json_resource, resource, attributes, strict = false) if json_resource.is_a?(Array) expect(json_resource).to have(1).resource json_resource = json_resource.first end match_attributes json_resource, resource, attributes, strict end |