Class: ActiveRecord::Defaults::Default
- Inherits:
-
Object
- Object
- ActiveRecord::Defaults::Default
- Defined in:
- lib/active_record/defaults.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute, value) ⇒ Default
constructor
A new instance of Default.
- #value(record) ⇒ Object
Constructor Details
#initialize(attribute, value) ⇒ Default
Returns a new instance of Default.
117 118 119 |
# File 'lib/active_record/defaults.rb', line 117 def initialize(attribute, value) @attribute, @value = attribute.to_s, value end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
115 116 117 |
# File 'lib/active_record/defaults.rb', line 115 def attribute @attribute end |
Instance Method Details
#value(record) ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/active_record/defaults.rb', line 121 def value(record) if @value.is_a?(Symbol) record.send(@value) elsif @value.respond_to?(:call) @value.call(record) else @value end end |