Class: GraphitiSpecHelpers::ErrorsProxy
- Inherits:
-
Object
- Object
- GraphitiSpecHelpers::ErrorsProxy
show all
- Includes:
- Enumerable
- Defined in:
- lib/graphiti_spec_helpers/errors_proxy.rb
Defined Under Namespace
Classes: Error
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ErrorsProxy.
38
39
40
|
# File 'lib/graphiti_spec_helpers/errors_proxy.rb', line 38
def initialize(array)
@errors = array.map { |e| Error.new(e) }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(id, *args, &blk) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/graphiti_spec_helpers/errors_proxy.rb', line 62
def method_missing(id, *args, &blk)
if error = @errors.select { |e| e.attribute.to_sym == id }
error = error[0] if error.length == 1
return error
else
super
end
end
|
Instance Method Details
#[](key) ⇒ Object
42
43
44
|
# File 'lib/graphiti_spec_helpers/errors_proxy.rb', line 42
def [](key)
@errors[key]
end
|
#each(&blk) ⇒ Object
46
47
48
|
# File 'lib/graphiti_spec_helpers/errors_proxy.rb', line 46
def each(&blk)
@errors.each(&blk)
end
|
#length ⇒ Object
50
51
52
|
# File 'lib/graphiti_spec_helpers/errors_proxy.rb', line 50
def length
count
end
|
#to_h ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/graphiti_spec_helpers/errors_proxy.rb', line 54
def to_h
{}.tap do |hash|
@errors.each do |e|
hash[e.attribute] = e.message
end
end
end
|