Class: Jade::Decode::Desc::Field

Inherits:
Data
  • Object
show all
Includes:
Node
Defined in:
lib/jade/decode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#decoded?

Instance Attribute Details

#innerObject (readonly)

Returns the value of attribute inner

Returns:

  • (Object)

    the current value of inner



108
109
110
# File 'lib/jade/decode.rb', line 108

def inner
  @inner
end

#keyObject (readonly)

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



108
109
110
# File 'lib/jade/decode.rb', line 108

def key
  @key
end

Instance Method Details

#decode(value) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/jade/decode.rb', line 111

def decode(value)
  h = coerce_hash(value)
  return type_err('Object', value) unless h

  raw = at_key(h, key.to_sym, key)
  return Failure.new(MissingField[key.to_s]) if ABSENT.equal?(raw)

  at_field(key.to_s, inner.decode(raw))
end