Module: AttrEncrypted::Adapters::ActiveRecord
- Defined in:
- lib/attr_encrypted/adapters/active_record.rb
Defined Under Namespace
Modules: Reload
Constant Summary collapse
- RAILS_VERSION =
Gem::Version.new(::ActiveRecord::VERSION::STRING).freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
:nodoc:.
Class Method Details
.extended(base) ⇒ Object
:nodoc:
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/attr_encrypted/adapters/active_record.rb', line 19 def self.extended(base) # :nodoc: base.class_eval do [:encode] = true class << self alias_method :method_missing_without_attr_encrypted, :method_missing alias_method :method_missing, :method_missing_with_attr_encrypted end def perform_attribute_assignment(method, new_attributes, *args) return if new_attributes.blank? send method, new_attributes.reject { |k, _| self.class.attr_encrypted_encrypted_attributes.key?(k.to_sym) }, *args send method, new_attributes.reject { |k, _| !self.class.attr_encrypted_encrypted_attributes.key?(k.to_sym) }, *args end private :perform_attribute_assignment if Gem::Requirement.new('> 3.1').satisfied_by?(RAILS_VERSION) alias_method :assign_attributes_without_attr_encrypted, :assign_attributes def assign_attributes(*args) perform_attribute_assignment :assign_attributes_without_attr_encrypted, *args end end alias_method :attributes_without_attr_encrypted=, :attributes= def attributes=(*args) perform_attribute_assignment :attributes_without_attr_encrypted=, *args end end end |