lib/rating/models/rating/rate.rb in rating-0.11.0 vs lib/rating/models/rating/rate.rb in rating-0.12.0

- old
+ new

@@ -17,11 +17,11 @@ validates :author_id, uniqueness: { case_sensitive: ::Rating::Config.validations['rate']['case_sensitive'], scope: ::Rating::Config.validations['rate']['scope'].map(&:to_sym), } - def self.create(author:, extra_scopes:, metadata:, resource:, scopeable: nil, value:) + def self.create(author:, extra_scopes:, metadata:, resource:, value:, scopeable: nil) attributes = { author: author, resource: resource, scopeable: scopeable }.merge(extra_scopes) record = find_or_initialize_by(attributes) metadata.each { |k, v| record[k] = v } if metadata.present? @@ -29,10 +29,10 @@ record.save record end - def self.rate_for(author:, extra_scopes: {}, resource:, scopeable: nil) + def self.rate_for(author:, resource:, extra_scopes: {}, scopeable: nil) find_by extra_scopes.merge(author: author, resource: resource, scopeable: scopeable) end private