Class: AlphaApi::DynamicSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/alpha_api/dynamic_setting.rb

Direct Known Subclasses

StringSymbolOrProcSetting

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setting) ⇒ DynamicSetting

Returns a new instance of DynamicSetting.



15
16
17
# File 'lib/alpha_api/dynamic_setting.rb', line 15

def initialize(setting)
  @setting = setting
end

Class Method Details

.build(setting, type) ⇒ Object



5
6
7
# File 'lib/alpha_api/dynamic_setting.rb', line 5

def self.build(setting, type)
  (type ? klass(type) : self).new(setting)
end

.klass(type) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/alpha_api/dynamic_setting.rb', line 9

def self.klass(type)
  klass = "#{type.to_s.camelcase}Setting"
  raise ArgumentError, "Unknown type: #{type}" unless AlphaApi.const_defined?(klass)
  AlphaApi.const_get(klass)
end

Instance Method Details

#value(*_args) ⇒ Object



19
20
21
# File 'lib/alpha_api/dynamic_setting.rb', line 19

def value(*_args)
  @setting
end