Class: Decidim::Toggle::InformativeCallouts::InformativeEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/toggle/informative_callouts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, message:, if_predicate: nil) ⇒ InformativeEntry

Returns a new instance of InformativeEntry.



30
31
32
33
34
# File 'lib/decidim/toggle/informative_callouts.rb', line 30

def initialize(type:, message:, if_predicate: nil)
  @type = type
  @message = message
  @if_predicate = if_predicate
end

Instance Attribute Details

#if_predicateObject (readonly)

Returns the value of attribute if_predicate.



28
29
30
# File 'lib/decidim/toggle/informative_callouts.rb', line 28

def if_predicate
  @if_predicate
end

#messageObject (readonly)

Returns the value of attribute message.



28
29
30
# File 'lib/decidim/toggle/informative_callouts.rb', line 28

def message
  @message
end

#typeObject (readonly)

Returns the value of attribute type.



28
29
30
# File 'lib/decidim/toggle/informative_callouts.rb', line 28

def type
  @type
end

Instance Method Details

#message_for(form) ⇒ Object



42
43
44
# File 'lib/decidim/toggle/informative_callouts.rb', line 42

def message_for(form)
  form.public_send(message)
end

#visible?(form) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
# File 'lib/decidim/toggle/informative_callouts.rb', line 36

def visible?(form)
  return true if if_predicate.nil?

  if_predicate.call(form)
end