Class: HasHelpers::Cards::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/has_helpers/cards/config.rb

Constant Summary collapse

MODES =
%i[server client].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



17
18
19
20
21
# File 'lib/has_helpers/cards/config.rb', line 17

def initialize
  @path = "/internal_graphql"
  @cache_ttl = 5.minutes
  @cache_stale_grace = 1.hour
end

Instance Attribute Details

#audienceObject

Returns the value of attribute audience.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def audience
  @audience
end

#base_urlObject

Returns the value of attribute base_url.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def base_url
  @base_url
end

#cache_stale_graceObject

Returns the value of attribute cache_stale_grace.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def cache_stale_grace
  @cache_stale_grace
end

#cache_ttlObject

Returns the value of attribute cache_ttl.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def cache_ttl
  @cache_ttl
end

#issuerObject

Returns the value of attribute issuer.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def issuer
  @issuer
end

#modeObject

Returns the value of attribute mode.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def mode
  @mode
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def path
  @path
end

#redisObject

Returns the value of attribute redis.



8
9
10
# File 'lib/has_helpers/cards/config.rb', line 8

def redis
  @redis
end

Instance Method Details

#validate!Object

Raises:



23
24
25
26
27
28
29
30
31
# File 'lib/has_helpers/cards/config.rb', line 23

def validate!
  self.mode = mode&.to_sym
  raise ConfigurationError, "mode is required" if mode.blank?
  raise ConfigurationError, "mode must be :server or :client" unless MODES.include?(mode)
  raise ConfigurationError, "issuer is required" if issuer.blank?

  validate_client! if mode == :client
  self
end