Module: AttributesHelper
- Defined in:
- app/helpers/attributes_helper.rb
Instance Method Summary collapse
- #array?(record, attribute) ⇒ Boolean
- #association?(model, attribute) ⇒ Boolean
- #belongs_to_association?(model, attribute) ⇒ Boolean
- #boolean?(record, attribute) ⇒ Boolean
- #has_one_association?(model, attribute) ⇒ Boolean
Instance Method Details
#array?(record, attribute) ⇒ Boolean
15 16 17 |
# File 'app/helpers/attributes_helper.rb', line 15 def array?(record, attribute) attribute_class?(record, attribute, Array) end |
#association?(model, attribute) ⇒ Boolean
3 4 5 |
# File 'app/helpers/attributes_helper.rb', line 3 def association?(model, attribute) !!model.reflect_on_association(attribute) end |
#belongs_to_association?(model, attribute) ⇒ Boolean
7 8 9 |
# File 'app/helpers/attributes_helper.rb', line 7 def belongs_to_association?(model, attribute) association_type?(model, attribute, :belongs_to) end |
#boolean?(record, attribute) ⇒ Boolean
19 20 21 |
# File 'app/helpers/attributes_helper.rb', line 19 def boolean?(record, attribute) ['false', 'true'].include? record.send(attribute).to_s end |
#has_one_association?(model, attribute) ⇒ Boolean
11 12 13 |
# File 'app/helpers/attributes_helper.rb', line 11 def has_one_association?(model, attribute) association_type?(model, attribute, :has_one) end |