Class: Nexter::Wrap
- Inherits:
-
Object
- Object
- Nexter::Wrap
- Defined in:
- lib/nexter/wrap.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
the current model & the scope.
-
#relation ⇒ Object
readonly
the current model & the scope.
Instance Method Summary collapse
- #after ⇒ Object
- #before ⇒ Object
-
#initialize(relation, model) ⇒ Wrap
constructor
A new instance of Wrap.
-
#next ⇒ Object
TODO : let user determine which strategy to choose: e.g: carousel or stay on last.
- #previous ⇒ Object
Constructor Details
Instance Attribute Details
#model ⇒ Object (readonly)
the current model & the scope
4 5 6 |
# File 'lib/nexter/wrap.rb', line 4 def model @model end |
#relation ⇒ Object (readonly)
the current model & the scope
4 5 6 |
# File 'lib/nexter/wrap.rb', line 4 def relation @relation end |
Instance Method Details
#after ⇒ Object
21 22 23 24 |
# File 'lib/nexter/wrap.rb', line 21 def after query = Query.new(model.values, :next) relation.where( query.wheres.join(' OR ') ) end |
#before ⇒ Object
26 27 28 29 30 |
# File 'lib/nexter/wrap.rb', line 26 def before query = Query.new(model.values, :previous) relation.where( query.wheres.join(' OR ') ). reorder( query.reorders.join(", ") ) end |
#next ⇒ Object
TODO : let user determine which strategy to choose: e.g: carousel or stay on last
13 14 15 |
# File 'lib/nexter/wrap.rb', line 13 def next @next||=after.first end |
#previous ⇒ Object
17 18 19 |
# File 'lib/nexter/wrap.rb', line 17 def previous @prev||=before.first end |