Class: Decidim::SettingsManifest::Attribute
Overview
Semi-private: Attributes are an abstraction used by SettingsManifest to encapsulate behavior related to each individual settings field. Should not be used from the outside.
Constant Summary
collapse
- TYPES =
{
boolean: { klass: Boolean, default: false },
integer: { klass: Integer, default: 0 },
string: { klass: String, default: nil },
float: { klass: Float, 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
126
127
128
|
# File 'lib/decidim/settings_manifest.rb', line 126
def build_choices
choices.try(:call) || choices
end
|
#default_value ⇒ Object
122
123
124
|
# File 'lib/decidim/settings_manifest.rb', line 122
def default_value
default || TYPES[type][:default]
end
|
#editor?(context) ⇒ Boolean
134
135
136
137
138
|
# File 'lib/decidim/settings_manifest.rb', line 134
def editor?(context)
return editor.call(context) if editor.respond_to?(:call)
editor
end
|
#readonly?(context) ⇒ Boolean
130
131
132
|
# File 'lib/decidim/settings_manifest.rb', line 130
def readonly?(context)
readonly&.call(context)
end
|
#type_class ⇒ Object
118
119
120
|
# File 'lib/decidim/settings_manifest.rb', line 118
def type_class
TYPES[type][:klass]
end
|