Class: Jade::Decode::Desc::OptField
- Inherits:
-
Data
- Object
- Data
- Jade::Decode::Desc::OptField
- Includes:
- Node
- Defined in:
- lib/jade/decode.rb
Instance Attribute Summary collapse
-
#inner ⇒ Object
readonly
Returns the value of attribute inner.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
Methods included from Node
Instance Attribute Details
#inner ⇒ Object (readonly)
Returns the value of attribute inner
122 123 124 |
# File 'lib/jade/decode.rb', line 122 def inner @inner end |
#key ⇒ Object (readonly)
Returns the value of attribute key
122 123 124 |
# File 'lib/jade/decode.rb', line 122 def key @key end |
Instance Method Details
#decode(value) ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/jade/decode.rb', line 125 def decode(value) h = coerce_hash(value) return type_err('Object', value) unless h raw = at_key(h, key.to_sym, key) return Jade::Maybe::Nothing[] if ABSENT.equal?(raw) decoded = inner.decode(raw) decoded?(decoded) ? Jade::Maybe::Just[decoded] : Failure.new(AtField[key.to_s, decoded.error]) end |