Class: Cursed::Adapter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cursed/adapter/base.rb

Direct Known Subclasses

ActiveRecord, Array, Sequel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/cursed/adapter/base.rb', line 8

def initialize(array)
  @relation = array
end

Instance Attribute Details

#relationObject (readonly)

Returns the value of attribute relation.



6
7
8
# File 'lib/cursed/adapter/base.rb', line 6

def relation
  @relation
end

Instance Method Details

#apply_to(cursor) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cursed/adapter/base.rb', line 12

def apply_to(cursor)
  attr = cursor.attribute

  after(attr, cursor.after) if cursor.after?

  before(attr, cursor.before) if cursor.before?

  if cursor.forward?
    ascend_by(attr)
  else
    descend_by(attr)
  end

  limit(cursor.clamped_limit)

  relation
end