Module: Koi::Helpers::AttributeHelpers
Defined Under Namespace
Classes: IntrospectedAttribute
Instance Method Summary
collapse
Instance Method Details
#collection_attribute_for(attribute) ⇒ Object
60
61
62
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 60
def collection_attribute_for(attribute)
AttributeTypes.for(attribute).collection_attribute
end
|
#default_sort_attribute ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 72
def default_sort_attribute
if orderable?
:ordinal
elsif (attribute = attributes.find { |attr| attr.type == :string })
attribute.name
else
attributes.first&.name
end
end
|
48
49
50
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 48
def govuk_input_for(attribute)
AttributeTypes.for(attribute).govuk_input
end
|
#index_attribute_for(attribute) ⇒ Object
52
53
54
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 52
def index_attribute_for(attribute)
AttributeTypes.for(attribute).index_row
end
|
#index_attributes ⇒ Object
64
65
66
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 64
def index_attributes
attributes.select { |attribute| index_attribute_for(attribute).present? }
end
|
#show_attribute_for(attribute) ⇒ Object
56
57
58
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 56
def show_attribute_for(attribute)
AttributeTypes.for(attribute).show_row
end
|
#show_attributes ⇒ Object
68
69
70
|
# File 'lib/generators/koi/helpers/attribute_helpers.rb', line 68
def show_attributes
attributes.select { |attribute| show_attribute_for(attribute).present? }
end
|