Method: Lookbook::StringValueCaster#initialize
- Defined in:
- lib/lookbook/services/string_value_caster.rb
#initialize(value, type = "string") ⇒ StringValueCaster
Returns a new instance of StringValueCaster.
5 6 7 8 9 10 11 12 13 |
# File 'lib/lookbook/services/string_value_caster.rb', line 5 def initialize(value, type = "string") @value = value.to_s @type = type.to_s.downcase @cast_method = :"cast_to_#{@type}" unless respond_to?(@cast_method) raise ArgumentError.new "'#{@type}' is not a valid value type to cast to." end end |