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