Module: AttributesHelper

Defined in:
app/helpers/attributes_helper.rb

Instance Method Summary collapse

Instance Method Details

#array?(record, attribute) ⇒ Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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