Module: Rows::Resources
- Included in:
- RowsController
- Defined in:
- lib/rows/resources.rb
Instance Method Summary collapse
- #resource ⇒ Object
- #resources ⇒ Object
- #set_resource(row = nil) ⇒ Object
- #set_resources(rows = nil) ⇒ Object
Instance Method Details
#resource ⇒ Object
4 5 6 |
# File 'lib/rows/resources.rb', line 4 def resource @_resource || set_resource end |
#resources ⇒ Object
8 9 10 |
# File 'lib/rows/resources.rb', line 8 def resources @_resources || set_resources end |
#set_resource(row = nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rows/resources.rb', line 12 def set_resource(row = nil) row ||= model_class.find_by_id(params[:id].to_i) instance_variable_set(:"@#{model_symbol}", row) @_resource = row @row = row end |
#set_resources(rows = nil) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rows/resources.rb', line 19 def set_resources(rows = nil) rows ||= model_class.all instance_variable_set(:"@#{model_symbol_plural}", rows) @_resources = rows @rows = rows end |