lib/generators/ahoy/messages/mongoid_generator.rb in ahoy_email-2.1.2 vs lib/generators/ahoy/messages/mongoid_generator.rb in ahoy_email-2.1.3
- old
+ new
@@ -11,11 +11,11 @@
class_option :unencrypted, type: :boolean
def copy_templates
case encryption
when "lockbox"
- template "mongoid_lockbox.rb", "app/models/ahoy/message.rb"
+ template "mongoid_lockbox.rb", "app/models/ahoy/message.rb", lockbox_method: lockbox_method
else
template "mongoid.rb", "app/models/ahoy/message.rb"
end
end
@@ -31,9 +31,17 @@
else
"lockbox"
end
else
abort "Error: encryption must be lockbox or none"
+ end
+ end
+
+ def lockbox_method
+ if defined?(Lockbox::VERSION) && Lockbox::VERSION.to_i < 1
+ "encrypts"
+ else
+ "has_encrypted"
end
end
end
end
end