Module: AttrEncrypted::Adapters::ActiveRecord
- Defined in:
- lib/attr_encrypted/adapters/active_record.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
:nodoc:.
Class Method Details
.extended(base) ⇒ Object
:nodoc:
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/attr_encrypted/adapters/active_record.rb', line 5 def self.extended(base) # :nodoc: base.class_eval do [:encode] = true class << self alias_method_chain :method_missing, :attr_encrypted if ::ActiveRecord::VERSION::STRING < "3" alias_method :undefine_attribute_methods, :reset_column_information end end if ::ActiveRecord::VERSION::STRING < "3.0" || ::ActiveRecord::VERSION::STRING > "3.1" def assign_attributes_with_attr_encrypted(*args) attributes = args.shift.symbolize_keys encrypted_attributes = self.class.encrypted_attributes.keys assign_attributes_without_attr_encrypted attributes.except(*encrypted_attributes), *args assign_attributes_without_attr_encrypted attributes.slice(*encrypted_attributes), *args end alias_method_chain :assign_attributes, :attr_encrypted else def attributes_with_attr_encrypted=(attributes) attributes = attributes.symbolize_keys encrypted_attributes = self.class.encrypted_attributes.keys self.attributes_without_attr_encrypted = attributes.except(*encrypted_attributes) self.attributes_without_attr_encrypted = attributes.slice(*encrypted_attributes) end alias_method_chain :attributes=, :attr_encrypted end end end |