Module: HasDynamicColumns::ActiveRecord::QueryMethods::WhereChainCompatibility
- Defined in:
- lib/has_dynamic_columns/active_record/query_methods.rb
Overview
Instance Method Summary collapse
-
#has_dynamic_columns(opts = :chain, *rest) ⇒ Object
Extends where to chain a has_dynamic_columns method This builds all the joins needed to search the has_dynamic_columns_data tables.
Instance Method Details
#has_dynamic_columns(opts = :chain, *rest) ⇒ Object
Extends where to chain a has_dynamic_columns method This builds all the joins needed to search the has_dynamic_columns_data tables
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/has_dynamic_columns/active_record/query_methods.rb', line 99 def has_dynamic_columns(opts = :chain, *rest) # Map dynamic_columns_value = { :scope => nil, :where => @scope.send(:build_where, opts, rest) } @scope.has_dynamic_columns_values = dynamic_columns_value chain = ::ActiveRecord::QueryMethods::WhereChain.new(@scope) chain.instance_eval do # Make outer scope variable accessible @dynamic_columns_value = dynamic_columns_value # Extends where to chain with a has_scope method # This scopes the where from above def with_scope(opt) @dynamic_columns_value[:scope] = opt @scope end def without_scope @scope end end chain end |