Class: MockPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/liaison/mock_presenter.rb

Instance Method Summary collapse

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

#errorsObject



16
17
18
# File 'lib/liaison/mock_presenter.rb', line 16

def errors
  @errors
end

#has_errors?(errors) ⇒ Boolean

Returns:

  • (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

Returns:

  • (Boolean)


24
25
26
# File 'lib/liaison/mock_presenter.rb', line 24

def has_no_errors?
  @errors.empty?
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/liaison/mock_presenter.rb', line 12

def valid?
  @errors.empty? && @valid
end