Class: IronNails::View::ViewModelCollection
Instance Method Summary
collapse
#[], #each, #initialize, #to_a
Instance Method Details
#<<(model) ⇒ Object
74
75
76
77
|
# File 'lib/ironnails/view/collections.rb', line 74
def <<(model)
@items << model unless has_viewmodel?(model)
find_viewmodel(model.__view_model_name_)
end
|
#find_viewmodel(name) ⇒ Object
70
71
72
|
# File 'lib/ironnails/view/collections.rb', line 70
def find_viewmodel(name)
self.find { |vm| vm.__view_model_name_ == name }
end
|
#has_viewmodel?(view_model) ⇒ Boolean
62
63
64
65
66
67
68
|
# File 'lib/ironnails/view/collections.rb', line 62
def has_viewmodel?(view_model)
if view_model.is_a?(String)
find_viewmodel(view_model).nil?
else
find_viewmodel(view_model.__view_model_name_).nil?
end
end
|