Class: AttrCoerced::Coercer

Inherits:
Struct
  • Object
show all
Defined in:
lib/attr_coerced/coercer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



6
7
8
# File 'lib/attr_coerced/coercer.rb', line 6

def default
  @default
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



6
7
8
# File 'lib/attr_coerced/coercer.rb', line 6

def type
  @type
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



6
7
8
# File 'lib/attr_coerced/coercer.rb', line 6

def value
  @value
end

Class Method Details

.get(*args) ⇒ Object



8
9
10
# File 'lib/attr_coerced/coercer.rb', line 8

def self.get(*args)
  new(*args).get
end

Instance Method Details

#getObject



12
13
14
# File 'lib/attr_coerced/coercer.rb', line 12

def get
  coerce(value) || coerce(default)
end