Class: Lego::Value::Array
Instance Method Summary collapse
-
#initialize(type, opts = {}) ⇒ Array
constructor
A new instance of Array.
- #parsers ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(type, opts = {}) ⇒ Array
Returns a new instance of Array.
4 5 6 7 |
# File 'lib/lego/value/array.rb', line 4 def initialize(type, opts={}) @_item_parser = Lego.value_parser(type) super(opts) end |
Instance Method Details
#parsers ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/lego/value/array.rb', line 9 def parsers [ ->(v) { v.respond_to?(:to_ary) ? Lego.just(v.to_ary) : Lego.fail("invalid array: '#{v}'") }, ->(v) { check_length? ? enforce_length(v) : Lego.just(v) }, ->(v) { parse_items(v) }, ->(v) { (not allow_empty? and v.empty?) ? Lego.none : Lego.just(v) } ] end |