class ActiveShepherd::Methods::QueryState
Public Instance Methods
handle_attribute(name, value)
click to toggle source
# File lib/active_shepherd/methods/query_state.rb, line 7 def handle_attribute(name, value) query[name] = value end
handle_has_many_association(reflection)
click to toggle source
# File lib/active_shepherd/methods/query_state.rb, line 11 def handle_has_many_association(reflection) association = aggregate.model.send reflection.name collection_state = association.map do |associated_model| self.class.query_state recurse(associated_model, reflection.foreign_key) end query[reflection.name] = collection_state unless collection_state.blank? end
handle_has_one_association(reflection)
click to toggle source
# File lib/active_shepherd/methods/query_state.rb, line 19 def handle_has_one_association(reflection) associated_model = aggregate.model.send reflection.name if associated_model state = self.class.query_state recurse(associated_model, reflection.foreign_key) query[reflection.name] = state unless state.blank? end end
query_state()
click to toggle source
# File lib/active_shepherd/methods/query_state.rb, line 2 def query_state traverse! query end
setup()
click to toggle source
Calls superclass method
ActiveShepherd::QueryMethod#setup
# File lib/active_shepherd/methods/query_state.rb, line 27 def setup super @attributes = aggregate.raw_attributes.each_with_object({}) do |(name,raw),h| next if aggregate.excluded_attributes.include? name value = aggregate.serialize_value name, raw unless value == aggregate.default_attributes[name] h[name.to_sym] = value end end end