Class: Ahoy::Generators::Messages::MongoidGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Ahoy::Generators::Messages::MongoidGenerator
- Defined in:
- lib/generators/ahoy/messages/mongoid_generator.rb
Instance Method Summary collapse
- #copy_templates ⇒ Object
-
#encryption ⇒ Object
TODO remove default.
- #lockbox_method ⇒ Object
Instance Method Details
#copy_templates ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/generators/ahoy/messages/mongoid_generator.rb', line 13 def copy_templates case encryption when "lockbox" template "mongoid_lockbox.rb", "app/models/ahoy/message.rb", lockbox_method: lockbox_method else template "mongoid.rb", "app/models/ahoy/message.rb" end end |
#encryption ⇒ Object
TODO remove default
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/ahoy/messages/mongoid_generator.rb', line 23 def encryption case [:encryption] when "lockbox", "none" [:encryption] when nil if [:unencrypted] # TODO deprecation warning "none" else "lockbox" end else abort "Error: encryption must be lockbox or none" end end |
#lockbox_method ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/generators/ahoy/messages/mongoid_generator.rb', line 39 def lockbox_method if defined?(Lockbox::VERSION) && Lockbox::VERSION.to_i < 1 "encrypts" else "has_encrypted" end end |