Class: MockPresenter
- Inherits:
-
Object
- Object
- MockPresenter
- Defined in:
- lib/liaison/mock_presenter.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add_errors(errs) ⇒ Object
- #errors ⇒ Object
- #has_errors?(errors) ⇒ Boolean
- #has_no_errors? ⇒ Boolean
-
#initialize(opts = {}) ⇒ MockPresenter
constructor
A new instance of MockPresenter.
- #valid? ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ MockPresenter
Returns a new instance of MockPresenter.
2 3 4 5 6 |
# File 'lib/liaison/mock_presenter.rb', line 2 def initialize(opts = {}) @valid = opts.delete(:valid) != false @fields = opts[:params] @errors = opts[:errors] || {} end |
Instance Method Details
#[](key) ⇒ Object
8 9 10 |
# File 'lib/liaison/mock_presenter.rb', line 8 def [](key) @fields[key] end |
#add_errors(errs) ⇒ Object
20 21 22 |
# File 'lib/liaison/mock_presenter.rb', line 20 def add_errors(errs) errs.each {|k,v| @errors[k] = v} end |
#errors ⇒ Object
16 17 18 |
# File 'lib/liaison/mock_presenter.rb', line 16 def errors @errors end |
#has_errors?(errors) ⇒ Boolean
28 29 30 |
# File 'lib/liaison/mock_presenter.rb', line 28 def has_errors?(errors) errors.all? {|k,v| @errors[k] == v} end |
#has_no_errors? ⇒ Boolean
24 25 26 |
# File 'lib/liaison/mock_presenter.rb', line 24 def has_no_errors? @errors.empty? end |
#valid? ⇒ Boolean
12 13 14 |
# File 'lib/liaison/mock_presenter.rb', line 12 def valid? @errors.empty? && @valid end |