Module: Deprecatable
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/acread/deprecatable.rb
Constant Summary collapse
- ACCESSORS =
[ '', '=', '_before_type_cast', '?', '_changed?', '_change', '_will_change!', '_was']
Instance Method Summary collapse
- #accessors ⇒ Object
- #deprecate_attribute(attr) ⇒ Object
- #deprecated_attributes ⇒ Object
- #overide_accessors(attr) ⇒ Object
Instance Method Details
#accessors ⇒ Object
15 16 17 18 |
# File 'lib/acread/deprecatable.rb', line 15 def accessors # TODO: replace this constant by an ActiveRecord inspection ACCESSORS end |
#deprecate_attribute(attr) ⇒ Object
5 6 7 8 9 |
# File 'lib/acread/deprecatable.rb', line 5 def deprecate_attribute attr @deprecated_attributes ||=[] @deprecated_attributes << attr.to_s overide_accessors attr end |
#deprecated_attributes ⇒ Object
11 12 13 |
# File 'lib/acread/deprecatable.rb', line 11 def deprecated_attributes @deprecated_attributes end |
#overide_accessors(attr) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/acread/deprecatable.rb', line 20 def overide_accessors attr msg = "You can't access atribute #{attr}, it has been deprecated" accessors.each do |term| define_method("#{attr}#{term}") do |*args| raise DeprecatedAttributeError, msg end end end |