Sha256: 9daf271d27595388d5341d9b934f5353567520fff9a8fa6bdeb91c9a9f4e1a85

Contents?: true

Size: 623 Bytes

Versions: 21

Compression:

Stored size: 623 Bytes

Contents

module ChannelQueryBuilder
    
  def build_query_from_filters(q, filters)
    filters.each do |filter, value|
      q = method("add_filter_for_#{filter}".to_sym).call(q, value)
    end
    return q
  end
    
  # Fucntion to add a limit to a given query
  def add_filter_for_limit(q, limit)
    q.limit(limit)
  end 
        
  def add_filter_for_category_id(q, category_id)
    q.joins(:categories).where(:ems_categories_channels => {:category_id => category_id})
  end
  
  def add_filter_for_slug(q, slug)
    q.where(:slug => slug)
  end 
  
  def add_filter_for_order_by(q, column)
    q.order column.to_sym
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
ems-0.1.12 lib/query_builder/channel_query_builder.rb
ems-0.1.11 lib/query_builder/channel_query_builder.rb
ems-0.1.10 lib/query_builder/channel_query_builder.rb
ems-0.1.9 lib/query_builder/channel_query_builder.rb
ems-0.1.8 lib/query_builder/channel_query_builder.rb
ems-0.1.7 lib/query_builder/channel_query_builder.rb
ems-0.1.6 lib/query_builder/channel_query_builder.rb
ems-0.1.5 lib/query_builder/channel_query_builder.rb
ems-0.1.4 lib/query_builder/channel_query_builder.rb
ems-0.1.3 lib/query_builder/channel_query_builder.rb
ems-0.1.2 lib/query_builder/channel_query_builder.rb
ems-0.1.1 lib/query_builder/channel_query_builder.rb
ems-0.1.0 lib/query_builder/channel_query_builder.rb
ems-0.0.9 lib/query_builder/channel_query_builder.rb
ems-0.0.8 lib/query_builder/channel_query_builder.rb
ems-0.0.7 lib/query_builder/channel_query_builder.rb
ems-0.0.6 lib/query_builder/channel_query_builder.rb
ems-0.0.5 lib/query_builder/channel_query_builder.rb
ems-0.0.4 lib/query_builder/channel_query_builder.rb
ems-0.0.3 lib/query_builder/channel_query_builder.rb