Class: Extant::Coercers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/extant/coercers/base.rb

Direct Known Subclasses

Array, Boolean, DateTime, Fixnum, Float, Hash, Integer, String, Symbol, Time, Uuid

Constant Summary collapse

UncoercedValue =
Extant::UncoercedValue

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, options = {}) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/extant/coercers/base.rb', line 9

def initialize(value, options={})
  self.value = value
  self.coerced = false
  self.options = {}
end

Class Method Details

.coercer_nameObject



5
6
7
# File 'lib/extant/coercers/base.rb', line 5

def self.coercer_name
  self.name.split("::").last.gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
end

Instance Method Details

#coerceObject



15
16
17
# File 'lib/extant/coercers/base.rb', line 15

def coerce
  rase NotImplementedError.new("#{self.class.name} must implement #{coerce}")
end

#coerced?Boolean

Returns:



19
20
21
# File 'lib/extant/coercers/base.rb', line 19

def coerced?
  coerced
end