Module: MadID
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mad_id.rb,
lib/mad_id/railtie.rb,
lib/mad_id/version.rb,
lib/mad_id/identity_methods.rb
Defined Under Namespace
Modules: FinderMethods, IdentityMethods Classes: Railtie
Constant Summary collapse
- VERSION =
"1.1.1"
Class Attribute Summary collapse
-
.registry ⇒ Object
Returns the value of attribute registry.
Class Method Summary collapse
Class Attribute Details
.registry ⇒ Object
Returns the value of attribute registry.
15 16 17 |
# File 'lib/mad_id.rb', line 15 def registry @registry end |
Class Method Details
.locate(id) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/mad_id.rb', line 17 def locate(id) prefix, _ = id.to_s.split('-', 2) if klass = registry[prefix] klass.find_by_mad_id(id) else nil end end |
.locate!(id) ⇒ Object
26 27 28 29 |
# File 'lib/mad_id.rb', line 26 def locate!(id) prefix, _ = id.to_s.split('-', 2) registry.fetch(prefix).find_by_mad_id!(id) end |