Class: GTFS::ORM::Resource::Scope
- Inherits:
-
Object
- Object
- GTFS::ORM::Resource::Scope
- Defined in:
- lib/gtfs/orm/resource.rb
Constant Summary collapse
- DEFAULT_LIMIT =
CONSTANTS
20.freeze
- DEFAULT_PAGE =
1.freeze
- DEFAULT_CONDITIONS =
{}.freeze
Instance Method Summary collapse
- #all ⇒ Object
- #first ⇒ Object
-
#initialize(collection) ⇒ Scope
constructor
INITIALIZER.
- #last ⇒ Object
-
#limit(limit = nil) ⇒ Object
INSTANCE METHODS.
- #page(page = nil) ⇒ Object
- #where(conditions = nil) ⇒ Object
Constructor Details
#initialize(collection) ⇒ Scope
INITIALIZER
70 71 72 73 74 75 |
# File 'lib/gtfs/orm/resource.rb', line 70 def initialize(collection) @collection = collection @limit = DEFAULT_LIMIT @page = DEFAULT_PAGE @conditions = DEFAULT_CONDITIONS end |
Instance Method Details
#all ⇒ Object
114 115 116 |
# File 'lib/gtfs/orm/resource.rb', line 114 def all scoped_collection end |
#first ⇒ Object
106 107 108 |
# File 'lib/gtfs/orm/resource.rb', line 106 def first all.first end |
#last ⇒ Object
110 111 112 |
# File 'lib/gtfs/orm/resource.rb', line 110 def last all.last end |
#limit(limit = nil) ⇒ Object
INSTANCE METHODS
79 80 81 82 83 84 85 86 |
# File 'lib/gtfs/orm/resource.rb', line 79 def limit(limit = nil) if limit @limit = limit return self else @limit end end |
#page(page = nil) ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/gtfs/orm/resource.rb', line 97 def page(page=nil) if page @page = page return self else @page end end |
#where(conditions = nil) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/gtfs/orm/resource.rb', line 88 def where(conditions = nil) if conditions @conditions = conditions return self else @conditions end end |