Class: Fierce::ViewModel
- Inherits:
-
Object
show all
- Defined in:
- lib/fierce/view_model.rb
Instance Method Summary
collapse
Constructor Details
#initialize(*presenters) ⇒ ViewModel
Returns a new instance of ViewModel.
3
4
5
|
# File 'lib/fierce/view_model.rb', line 3
def initialize(*presenters)
@presenters = presenters
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/fierce/view_model.rb', line 7
def method_missing(method, *args, &block)
responder = @presenters.find do |delegate|
delegate.respond_to?(method, include_private=true)
end
responder ? responder.send(method, *args, &block) : super
end
|
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
15
16
17
|
# File 'lib/fierce/view_model.rb', line 15
def respond_to?(method, include_private=false)
super(method, include_private) || @presenters.any?{|p| p.respond_to?(method)}
end
|
#yield(area = :layout) ⇒ Object
19
20
21
|
# File 'lib/fierce/view_model.rb', line 19
def yield(area = :layout)
content_for(area)
end
|