Module: CustomAttributes::ActsAsCustomValue::InstanceMethods
- Defined in:
- lib/custom_attributes/acts_as/acts_as_custom_value.rb
Instance Method Summary collapse
- #initialize(attributes = nil, *args) ⇒ Object
- #required? ⇒ Boolean
- #to_s ⇒ Object
- #true? ⇒ Boolean
- #visible? ⇒ Boolean
Instance Method Details
#initialize(attributes = nil, *args) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/custom_attributes/acts_as/acts_as_custom_value.rb', line 20 def initialize(attributes = nil, *args) super if new_record? && custom_field && !attributes.key?(:value) self.value ||= custom_field.default end end |
#required? ⇒ Boolean
35 36 37 |
# File 'lib/custom_attributes/acts_as/acts_as_custom_value.rb', line 35 def required? custom_field.is_required? end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/custom_attributes/acts_as/acts_as_custom_value.rb', line 39 def to_s value.to_s end |
#true? ⇒ Boolean
27 28 29 |
# File 'lib/custom_attributes/acts_as/acts_as_custom_value.rb', line 27 def true? value == '1' end |
#visible? ⇒ Boolean
31 32 33 |
# File 'lib/custom_attributes/acts_as/acts_as_custom_value.rb', line 31 def visible? custom_field.visible? end |