Module: HumanID::Extension::Generation
- Defined in:
- lib/humanid/extension/generation.rb
Class Method Summary collapse
Class Method Details
.generate(human_id, model) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/humanid/extension/generation.rb', line 8 def generate(human_id, model) = model.send("options_for_#{human_id}") pattern = .fetch(:compiled_pattern) data = HumanID::Extension::Pattern.result(pattern, model) HumanID.engine([:engine]).perform(data) end |
.ready_to_generate?(model) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/humanid/extension/generation.rb', line 15 def ready_to_generate?(model) # Sometimes human id depends on record id or timestamps. # When record isn't persisted human id will be generated wrong. model.persisted? end |