Sha256: 722f85390bac971a4b955886b4c1063ff5f809f60abd8475aec63795e4a6a47c
Contents?: true
Size: 834 Bytes
Versions: 2
Compression:
Stored size: 834 Bytes
Contents
require "hario/version" require "hario/behaviours/filter" require "hario/behaviours/pluck" module Hario module Filterable extend ActiveSupport::Concern module ClassMethods def search(filters, pluck = nil) s = all s = s.apply_filters(filters) if filters s = s.apply_pluck(pluck) if pluck s end def apply_filters(filters) fp = FilterParser.new(filters, self) fp.where_clauses.reduce(joins(fp.join_clause), &:where) end def apply_pluck(pluck) pp = PluckParser.new(pluck, self) results = hash_pluck(*pp.pluck_clause) remove_local_table_prefix(results) end def remove_local_table_prefix(results) results.map{ |r| r.transform_keys!{ |k| k.gsub(/^#{table_name}\./, '') } } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hario-0.1.1 | lib/hario.rb |
hario-0.1.0 | lib/hario.rb |