module ActsAsHashids::Core::ClassMethods

Public Instance Methods

has_many(*args, &block) click to toggle source
Calls superclass method
# File lib/acts_as_hashids/core.rb, line 60
def has_many(*args, &block) # rubocop:disable Naming/PredicateName
  options = args.extract_options!
  options[:extend] = (options[:extend] || []).concat([FinderMethods])
  super(*args, **options, &block)
end
relation() click to toggle source
Calls superclass method
# File lib/acts_as_hashids/core.rb, line 66
def relation
  r = super
  r.extend FinderMethods
  r
end
with_hashids(*ids) click to toggle source
# File lib/acts_as_hashids/core.rb, line 52
def with_hashids(*ids)
  ids = ids.flatten
  decoded_ids = ids.map { |id| hashids.decode(id) }.flatten
  raise ActsAsHashids::Exception, "Decode error: #{ids.inspect}" if ids.size != decoded_ids.size

  where(primary_key => decoded_ids)
end