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 Style/PredicateName.
- #relation ⇒ Object
- #with_hashids(*ids) ⇒ Object
Methods included from FinderMethods
Instance Method Details
#has_many(*args, &block) ⇒ Object
rubocop:disable Style/PredicateName
52 53 54 55 56 |
# File 'lib/acts_as_hashids/core.rb', line 52 def has_many(*args, &block) # rubocop:disable Style/PredicateName = args. [:extend] = ([:extend] || []).concat([FinderMethods]) super(*args, , &block) end |
#relation ⇒ Object
58 59 60 61 62 |
# File 'lib/acts_as_hashids/core.rb', line 58 def relation r = super r.extend FinderMethods r end |
#with_hashids(*ids) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/acts_as_hashids/core.rb', line 44 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 |