Class: KiltViewModel
- Inherits:
-
Object
show all
- Defined in:
- lib/kilt_view_model.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(subject = {}) ⇒ KiltViewModel
Returns a new instance of KiltViewModel.
8
9
10
|
# File 'lib/kilt_view_model.rb', line 8
def initialize subject = {}
@subject = subject
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
16
17
18
|
# File 'lib/kilt_view_model.rb', line 16
def method_missing(meth, *args, &blk)
@subject[meth.to_s] || @subject[meth]
end
|
Class Method Details
.build(input) ⇒ Object
3
4
5
6
|
# File 'lib/kilt_view_model.rb', line 3
def self.build input
this_is_a_collection(input) ? build_view_models_from(input)
: build_a_view_model_from(input)
end
|
Instance Method Details
#[](id) ⇒ Object
12
13
14
|
# File 'lib/kilt_view_model.rb', line 12
def [] id
@subject[id.to_s] || @subject[id.to_s.to_sym]
end
|