Module: ActsAsHashids::Core::ClassMethods
- Includes:
- FinderMethods
- Defined in:
- lib/acts_as_hashids/core.rb
Instance Method Summary collapse
-
#has_many(*args, &block) ⇒ Object
rubocop:disable Naming/PredicateName.
- #relation ⇒ Object
- #with_hashids(*ids) ⇒ Object
Methods included from FinderMethods
Instance Method Details
#has_many(*args, &block) ⇒ Object
rubocop:disable Naming/PredicateName
60 61 62 63 64 |
# File 'lib/acts_as_hashids/core.rb', line 60 def has_many(*args, &block) # rubocop:disable Naming/PredicateName = args. [:extend] = ([:extend] || []).concat([FinderMethods]) super(*args, **, &block) end |
#relation ⇒ Object
66 67 68 69 70 |
# File 'lib/acts_as_hashids/core.rb', line 66 def relation r = super r.extend FinderMethods r end |
#with_hashids(*ids) ⇒ Object
52 53 54 55 56 57 58 |
# 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 |