aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attributes/aliasing.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/attributes/aliasing.rb')
-rw-r--r--activerecord/lib/active_record/attributes/aliasing.rb42
1 files changed, 0 insertions, 42 deletions
diff --git a/activerecord/lib/active_record/attributes/aliasing.rb b/activerecord/lib/active_record/attributes/aliasing.rb
deleted file mode 100644
index db77739d1f..0000000000
--- a/activerecord/lib/active_record/attributes/aliasing.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-module ActiveRecord
- module Attributes
- module Aliasing
- # Allows access to keys using aliased names.
- #
- # Example:
- # class Attributes < Hash
- # include Aliasing
- # end
- #
- # attributes = Attributes.new
- # attributes.aliases['id'] = 'fancy_primary_key'
- # attributes['fancy_primary_key'] = 2020
- #
- # attributes['id']
- # => 2020
- #
- # Additionally, symbols are always aliases of strings:
- # attributes[:fancy_primary_key]
- # => 2020
- #
- def [](key)
- super(unalias(key))
- end
-
- def []=(key, value)
- super(unalias(key), value)
- end
-
- def aliases
- @aliases ||= {}
- end
-
- def unalias(key)
- key = key.to_s
- aliases[key] || key
- end
-
- end
- end
-end
-