Module: ActiveRecord::Attributes
- Defined in:
- lib/activerecord-attributes.rb
Defined Under Namespace
Classes: AttributeError
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.with_assertions? ⇒ Boolean
22 23 24 |
# File 'lib/activerecord-attributes.rb', line 22 def self.with_assertions? !@disable_assertions end |
.without_assertions ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/activerecord-attributes.rb', line 14 def self.without_assertions current = @disable_assertions @disable_assertions = true yield ensure @disable_assertions = current end |
Instance Method Details
#attribute(name) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/activerecord-attributes.rb', line 7 def attribute(name) return unless ActiveRecord::Attributes.with_assertions? unless attribute_names.include? name.to_s fail AttributeError, "#{self} does not actually have an attribute named #{name}" end end |