Class: Tickethub::Errors
- Inherits:
-
Object
show all
- Defined in:
- lib/tickethub/errors.rb
Instance Method Summary
collapse
Constructor Details
#initialize(errors) ⇒ Errors
Returns a new instance of Errors.
4
5
6
|
# File 'lib/tickethub/errors.rb', line 4
def initialize(errors)
@errors = errors || {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments) ⇒ Object
30
31
32
|
# File 'lib/tickethub/errors.rb', line 30
def method_missing(method, *arguments)
on(method) || []
end
|
Instance Method Details
#[](key) ⇒ Object
24
25
26
|
# File 'lib/tickethub/errors.rb', line 24
def [](key)
send key
end
|
#full_messages_for(attribute) ⇒ Object
8
9
10
|
# File 'lib/tickethub/errors.rb', line 8
def full_messages_for(attribute)
send attribute
end
|
#invalid?(attribute) ⇒ Boolean
20
21
22
|
# File 'lib/tickethub/errors.rb', line 20
def invalid?(attribute)
send(attribute).any?
end
|
#on(attribute) ⇒ Object
12
13
14
|
# File 'lib/tickethub/errors.rb', line 12
def on(attribute)
@errors[attribute.to_s]
end
|
#valid?(attribute) ⇒ Boolean
16
17
18
|
# File 'lib/tickethub/errors.rb', line 16
def valid?(attribute)
send(attribute).empty?
end
|