lib/plain_model/querying/where.rb in plain_model-0.1.0 vs lib/plain_model/querying/where.rb in plain_model-0.2.0

- old
+ new

@@ -5,25 +5,26 @@ module PlainModel module Querying module Where extend ActiveSupport::Concern - def initialize(*args) - super(*args) - values[:where] = {} + def initial_values + super.merge where: [] end - included do - self.chainable_methods += [:except] + # Chain method + # @param conditions [Array] + # @return new instance with applied changes + def where(*conditions) + dup.where!(*conditions) end # Chain method - # @param conditions [Hash] - # @return new instance with applied changes - def where(conditions) - _within_new_instance do - values[:where].merge!(conditions) - end + # @param conditions [Array] + # @return current instance with applied changes + def where!(*conditions) + values[:where] = (values[:where] + conditions).uniq + self end end end end