Class: Decidim::ReminderManifest
- Inherits:
-
Object
- Object
- Decidim::ReminderManifest
- Includes:
- ActiveModel::Model, AttributeObject::Model
- Defined in:
- lib/decidim/reminder_manifest.rb
Overview
This class acts as a manifest for reminders.
This manifest is a simple object that holds and stores reminder and it’s generator class.
Defined Under Namespace
Classes: ReminderManifestMessages
Constant Summary
Constants included from AttributeObject::TypeMap
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #command_class ⇒ Object
- #form_class ⇒ Object
- #generator_class ⇒ Object
-
#has_message?(key) ⇒ Boolean
Returns a boolean indicating whether the message exists with the given key.
- #has_settings? ⇒ Boolean
-
#initialize(name:) ⇒ ReminderManifest
constructor
A new instance of ReminderManifest.
- #message(key, context = nil, **extra, &block) ⇒ Object
-
#messages ⇒ Object
Fetch the messages object or yield it for the block when a block is given.
- #settings {|@settings| ... } ⇒ Object
Methods included from AttributeObject::Model
#[], #[]=, #attributes, #attributes_with_values, #to_h
Constructor Details
#initialize(name:) ⇒ ReminderManifest
Returns a new instance of ReminderManifest.
20 21 22 23 24 |
# File 'lib/decidim/reminder_manifest.rb', line 20 def initialize(name:) super() @name = name @messages = ReminderManifestMessages.new end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/decidim/reminder_manifest.rb', line 18 def name @name end |
Instance Method Details
#command_class ⇒ Object
34 35 36 |
# File 'lib/decidim/reminder_manifest.rb', line 34 def command_class command_class_name.constantize end |
#form_class ⇒ Object
30 31 32 |
# File 'lib/decidim/reminder_manifest.rb', line 30 def form_class form_class_name.constantize end |
#generator_class ⇒ Object
26 27 28 |
# File 'lib/decidim/reminder_manifest.rb', line 26 def generator_class generator_class_name.constantize end |
#has_message?(key) ⇒ Boolean
Returns a boolean indicating whether the message exists with the given key.
69 70 71 |
# File 'lib/decidim/reminder_manifest.rb', line 69 def (key) .has?(key) end |
#has_settings? ⇒ Boolean
38 39 40 |
# File 'lib/decidim/reminder_manifest.rb', line 38 def has_settings? settings.attributes.any? end |
#message(key, context = nil, **extra, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/decidim/reminder_manifest.rb', line 58 def (key, context = nil, **extra, &block) extra = context if extra.empty? && context.is_a?(Hash) if block_given? .set(key, &block) else .render(key, context, **extra) end end |
#messages ⇒ Object
Fetch the messages object or yield it for the block when a block is given.
50 51 52 53 54 55 56 |
# File 'lib/decidim/reminder_manifest.rb', line 50 def if block_given? yield @messages else @messages end end |
#settings {|@settings| ... } ⇒ Object
42 43 44 45 46 |
# File 'lib/decidim/reminder_manifest.rb', line 42 def settings(&block) @settings ||= SettingsManifest.new yield(@settings) if block @settings end |