Class: Banacle::Slack::Confirm

Inherits:
Struct
  • Object
show all
Defined in:
lib/banacle/slack.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_textObject

Returns the value of attribute dismiss_text

Returns:

  • (Object)

    the current value of dismiss_text



159
160
161
# File 'lib/banacle/slack.rb', line 159

def dismiss_text
  @dismiss_text
end

#ok_textObject

Returns the value of attribute ok_text

Returns:

  • (Object)

    the current value of ok_text



159
160
161
# File 'lib/banacle/slack.rb', line 159

def ok_text
  @ok_text
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



159
160
161
# File 'lib/banacle/slack.rb', line 159

def text
  @text
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



159
160
161
# File 'lib/banacle/slack.rb', line 159

def title
  @title
end

Class Method Details

.approveObject



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_jsonObject



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