Skip to content

Commit

Permalink
Override attributes method using anon module
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed Jul 16, 2017
1 parent 049a5f9 commit d8fe42f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/mobility/active_record/attribute_methods.rb
Expand Up @@ -13,13 +13,15 @@ module AttributeMethods
# @return [Array<String>] Model attributes
# @!method attributes
def self.included(model)
model.class_eval do
alias_method :untranslated_attributes, :attributes

attributes_method = Module.new do
def attributes
super.merge(translated_attributes)
end
end
model.class_eval do
alias_method :untranslated_attributes, :attributes
include attributes_method
end
end

# Translated attributes defined on model.
Expand Down

0 comments on commit d8fe42f

Please sign in to comment.