Class: Sinatra::Pagers::PagerAdsQueryAdapter
- Inherits:
 - 
      Object
      
        
- Object
 - Sinatra::Pagers::PagerAdsQueryAdapter
 
 
- Defined in:
 - lib/sinatra/pagers.rb
 
Instance Attribute Summary collapse
- 
  
    
      #cds_out  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute cds_out.
 
Instance Method Summary collapse
- 
  
    
      #initialize(pager, ads, cds_pre, no_query: false)  ⇒ PagerAdsQueryAdapter 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of PagerAdsQueryAdapter.
 - #process ⇒ Object
 
Constructor Details
#initialize(pager, ads, cds_pre, no_query: false) ⇒ PagerAdsQueryAdapter
Returns a new instance of PagerAdsQueryAdapter.
      50 51 52 53 54 55 56 57  | 
    
      # File 'lib/sinatra/pagers.rb', line 50 def initialize(pager, ads, cds_pre, no_query:false) @pager=pager @ads=ads @cds_pre=cds_pre @cds_out=@cds_pre @no_query=no_query process end  | 
  
Instance Attribute Details
#cds_out ⇒ Object (readonly)
Returns the value of attribute cds_out.
      49 50 51  | 
    
      # File 'lib/sinatra/pagers.rb', line 49 def cds_out @cds_out end  | 
  
Instance Method Details
#process ⇒ Object
      59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86  | 
    
      # File 'lib/sinatra/pagers.rb', line 59 def process cd_ids=@cds_pre.map(:id) if @pager.extra[:decision] and @pager.extra[:decision]!="_no_" cd_ids_decision=@ads.decision_by_cd.find_all {|v| @pager.extra[:decision]==v[1] }.map {|v| v[0]} cd_ids=cd_ids & cd_ids_decision end if @pager.extra[:tag_select] =[@pager.extra[:tag_select]].flatten #$log.info(selected_tags) sr=@ads.systematic_review cd_id_tag=.map {|tag_id| TagInCd.cds_rs_tag(sr,Tag[tag_id],true).map(:id) }.flatten.uniq cd_ids=cd_ids & cd_id_tag end if @pager.query and !@no_query query=@pager.query query="title(#{@pager.query})" unless query=~/\(|\)/ sp=Buhos::SearchParser.new sp.parse(query) cd_ids = cd_ids & @cds_pre.where(Sequel.lit(sp.to_sql)).select_map(:id) end @cds_out=@cds_pre.where(:id => cd_ids) end  |