Class: FeatureHub::Sdk::InterceptorValue

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_hub/sdk/interceptors.rb

Overview

represents an intercepted value

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ InterceptorValue

Returns a new instance of InterceptorValue.



7
8
9
# File 'lib/feature_hub/sdk/interceptors.rb', line 7

def initialize(val)
  @val = val
end

Instance Method Details

#cast(expected_type) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/feature_hub/sdk/interceptors.rb', line 11

def cast(expected_type)
  return @val if expected_type.nil? || @val.nil?

  case expected_type
  when "BOOLEAN"
    @val.to_s.downcase.strip == "true"
  when "NUMBER"
    @val.to_s.to_f
  else
    @val.to_s
  end
end