class Setka::Workflow::Configuration

Constants

CONFIGURABLE_ATTRIBUTES

Public Class Methods

configurable_attributes() click to toggle source
# File lib/setka/workflow/configuration.rb, line 11
def self.configurable_attributes
  CONFIGURABLE_ATTRIBUTES
end
new(attrs = {}) click to toggle source
# File lib/setka/workflow/configuration.rb, line 15
def initialize(attrs = {})
  self.attributes = attrs
end

Public Instance Methods

access_token=(value) click to toggle source
# File lib/setka/workflow/configuration.rb, line 29
def access_token=(value)
  validate_string_value(:access_token, value)

  @access_token = value
end
attributes=(attrs = {}) click to toggle source
# File lib/setka/workflow/configuration.rb, line 19
def attributes=(attrs = {})
  attrs.each do |key, value|
    if CONFIGURABLE_ATTRIBUTES.include?(key)
      validate_string_value(key, value)

      instance_variable_set("@#{key}", value)
    end
  end
end
credentials() click to toggle source
# File lib/setka/workflow/configuration.rb, line 41
def credentials
  { access_token: access_token, space_name: space_name }
end
credentials?() click to toggle source
# File lib/setka/workflow/configuration.rb, line 45
def credentials?
  validate_credentials_presence
end
space_name=(value) click to toggle source
# File lib/setka/workflow/configuration.rb, line 35
def space_name=(value)
  validate_string_value(:space_name, value)

  @space_name = value
end

Private Instance Methods

validate_credentials_presence() click to toggle source
# File lib/setka/workflow/configuration.rb, line 51
def validate_credentials_presence
  unless credentials.values.all?
    message = credentials.select {|_, v| v.nil? }
      .map {|k, _| "#{k} is not specified"}
      .join(', ')

    raise ConfigurationError.new(message)
  end
end
validate_string_value(key, value) click to toggle source
# File lib/setka/workflow/configuration.rb, line 61
def validate_string_value(key, value)
  raise ConfigurationError.new("#{key} must be a filled string") unless
    value.is_a?(String) && value.length > 0
end