Class: Banacle::Slack::Confirm
- Inherits:
-
Struct
- Object
- Struct
- Banacle::Slack::Confirm
- Defined in:
- lib/banacle/slack.rb
Instance Attribute Summary collapse
-
#dismiss_text ⇒ Object
Returns the value of attribute dismiss_text.
-
#ok_text ⇒ Object
Returns the value of attribute ok_text.
-
#text ⇒ Object
Returns the value of attribute text.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(*args) ⇒ Confirm
constructor
A new instance of Confirm.
- #set_default! ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(*args) ⇒ Confirm
Returns a new instance of Confirm.
164 165 166 167 168 169 |
# File 'lib/banacle/slack.rb', line 164 def initialize(*args) super self.set_default! self.validate! self end |
Instance Attribute Details
#dismiss_text ⇒ Object
Returns the value of attribute dismiss_text
159 160 161 |
# File 'lib/banacle/slack.rb', line 159 def dismiss_text @dismiss_text end |
#ok_text ⇒ Object
Returns the value of attribute ok_text
159 160 161 |
# File 'lib/banacle/slack.rb', line 159 def ok_text @ok_text end |
#text ⇒ Object
Returns the value of attribute text
159 160 161 |
# File 'lib/banacle/slack.rb', line 159 def text @text end |
#title ⇒ Object
Returns the value of attribute title
159 160 161 |
# File 'lib/banacle/slack.rb', line 159 def title @title end |
Class Method Details
.approve ⇒ Object
160 161 162 |
# File 'lib/banacle/slack.rb', line 160 def self.approve self.new(text: 'The operation will be performed immediately.') end |
Instance Method Details
#as_json ⇒ Object
186 187 188 |
# File 'lib/banacle/slack.rb', line 186 def as_json self.to_h end |
#set_default! ⇒ Object
171 172 173 174 175 176 |
# File 'lib/banacle/slack.rb', line 171 def set_default! self.title ||= 'Are you sure?' self.text ||= '' self.ok_text ||= 'Yes' self.dismiss_text ||= 'No' end |
#validate! ⇒ Object
178 179 180 181 182 183 184 |
# File 'lib/banacle/slack.rb', line 178 def validate! %i(title text ok_text dismiss_text).each do |label| unless self.send(label).is_a?(String) raise ValidationError.new("#{attr} must be String") end end end |