Class: Sinatra::Pagers::PagerCdQueryAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/pagers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pager, cds_pre) ⇒ PagerCdQueryAdapter

Returns a new instance of PagerCdQueryAdapter.



32
33
34
35
36
37
# File 'lib/sinatra/pagers.rb', line 32

def initialize(pager, cds_pre)
  @pager=pager
  @cds_pre=cds_pre
  @cds_out=@cds_pre
  process
end

Instance Attribute Details

#cds_outObject (readonly)

Returns the value of attribute cds_out.



31
32
33
# File 'lib/sinatra/pagers.rb', line 31

def cds_out
  @cds_out
end

Instance Method Details

#processObject



38
39
40
41
42
43
44
45
# File 'lib/sinatra/pagers.rb', line 38

def process
  if @pager.query.to_s!=""
    cd_ids=@cds_pre.find_all {|v|
      v[:title].include? @pager.query or v[:author].include? @pager.query
    }.map {|v| v[0]}
    @cds_out=@cds_pre.where(:id => cd_ids)
  end
end