Class: Decidim::SettingsManifest::Attribute
Overview
Semi-private: Attributes are an abstraction used by SettingsManifest to encapsulate behavior related to each individual settings field. Shouldn’t be used from the outside.
Constant Summary
collapse
- TYPES =
{
boolean: { klass: Boolean, default: false },
integer: { klass: Integer, default: 0 },
string: { klass: String, default: nil },
text: { klass: String, default: nil },
array: { klass: Array, default: [] },
enum: { klass: String, default: nil },
select: { klass: String, default: nil },
scope: { klass: Integer, default: nil },
time: { klass: Decidim::Attributes::TimeWithZone, default: nil }
}.freeze
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Method Summary
collapse
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#build_choices ⇒ Object
125
126
127
|
# File 'lib/decidim/settings_manifest.rb', line 125
def build_choices
choices.try(:call) || choices
end
|
#default_value ⇒ Object
121
122
123
|
# File 'lib/decidim/settings_manifest.rb', line 121
def default_value
default || TYPES[type][:default]
end
|
#readonly?(context) ⇒ Boolean
129
130
131
|
# File 'lib/decidim/settings_manifest.rb', line 129
def readonly?(context)
readonly&.call(context)
end
|
#type_class ⇒ Object
117
118
119
|
# File 'lib/decidim/settings_manifest.rb', line 117
def type_class
TYPES[type][:klass]
end
|