Class: Decidim::ReminderManifest

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, AttributeObject::Model
Defined in:
decidim-core/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 is generator class.

Defined Under Namespace

Classes: ReminderManifestMessages

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Attribute Summary collapse

Instance Method Summary collapse

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 'decidim-core/lib/decidim/reminder_manifest.rb', line 20

def initialize(name:)
  super()
  @name = name
  @messages = ReminderManifestMessages.new
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 18

def name
  @name
end

Instance Method Details

#command_classObject



34
35
36
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 34

def command_class
  command_class_name.constantize
end

#form_classObject



30
31
32
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 30

def form_class
  form_class_name.constantize
end

#generator_classObject



26
27
28
# File 'decidim-core/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.

Returns:



69
70
71
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 69

def has_message?(key)
  messages.has?(key)
end

#has_settings?Boolean

Returns:



38
39
40
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 38

def has_settings?
  settings.attributes.any?
end

#message(key, context = nil, **extra) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 58

def message(key, context = nil, **extra, &)
  extra = context if extra.empty? && context.is_a?(Hash)

  if block_given?
    messages.set(key, &)
  else
    messages.render(key, context, **extra)
  end
end

#messagesObject

Fetch the messages object or yield it for the block when a block is given.



50
51
52
53
54
55
56
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 50

def messages
  if block_given?
    yield @messages
  else
    @messages
  end
end

#settings {|@settings| ... } ⇒ Object

Yields:



42
43
44
45
46
# File 'decidim-core/lib/decidim/reminder_manifest.rb', line 42

def settings(&block)
  @settings ||= SettingsManifest.new
  yield(@settings) if block
  @settings
end