Class: Espresso::Collection
- Inherits:
-
Array
- Object
- Array
- Espresso::Collection
- Defined in:
- lib/espresso/collection.rb,
lib/espresso/collection/searchlogic.rb,
lib/espresso/collection/will_paginate.rb
Overview
Represents collection of resources. Used in Espresso::Controller InheritedResources extension
Instance Attribute Summary collapse
-
#base ⇒ ActiveRecord::Base
Use ActiveRecord::Base#searchlogic method to generate base for finding the collection.
-
#collection ⇒ WillPaginate::Collection
Finds collection by ActiveRecord::Base.paginate method and options provided in #initialize method.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#search ⇒ Object
Returns the value of attribute search.
Instance Method Summary collapse
-
#initialize(base, options = {}) ⇒ Collection
constructor
Initiates a collection of resources.
Constructor Details
#initialize(base, options = {}) ⇒ Collection
Initiates a collection of resources
20 21 22 23 |
# File 'lib/espresso/collection.rb', line 20 def initialize(base, = {}) @base, @options = base, replace(collection) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object (protected)
Proxy to #collection methods
32 33 34 |
# File 'lib/espresso/collection.rb', line 32 def method_missing(method_name, *args) collection.send(method_name, *args) end |
Instance Attribute Details
#base ⇒ ActiveRecord::Base
Use ActiveRecord::Base#searchlogic method to generate base for finding the collection
9 10 11 |
# File 'lib/espresso/collection/searchlogic.rb', line 9 def base @base end |
#collection ⇒ WillPaginate::Collection
Finds collection by ActiveRecord::Base.paginate method and options provided in #initialize method
27 28 29 |
# File 'lib/espresso/collection.rb', line 27 def collection @collection end |
#options=(value) ⇒ Object
Sets the attribute options
11 12 13 |
# File 'lib/espresso/collection.rb', line 11 def (value) @options = value end |
#search ⇒ Object
Returns the value of attribute search.
11 12 13 |
# File 'lib/espresso/collection.rb', line 11 def search @search end |