Module: CanTango::Permit::Attribute::TestAttribute

Included in:
CanTango::Permit::Attribute, Builder
Defined in:
lib/cantango/permit/attribute.rb

Instance Method Summary collapse

Instance Method Details

#plural_attributeObject



26
27
28
# File 'lib/cantango/permit/attribute.rb', line 26

def plural_attribute
  @pl ||= attribute.to_s.pluralize
end

#test_pluralObject



39
40
41
42
# File 'lib/cantango/permit/attribute.rb', line 39

def test_plural
  return false unless subject.respond_to?(plural_attribute)
  subject.send(plural_attribute).include? attribute
end

#test_singleObject



34
35
36
37
# File 'lib/cantango/permit/attribute.rb', line 34

def test_single
  return false unless subject.respond_to?(attribute)
  subject.send(attribute) == attribute
end

#valid?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/cantango/permit/attribute.rb', line 30

def valid?
  test_single || test_plural
end