Module: StrokeDB::Coercions
- Defined in:
- lib/strokedb/document/dsl/coercions.rb
Instance Method Summary collapse
Instance Method Details
#coerces(slotnames, opts = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/strokedb/document/dsl/coercions.rb', line 3 def coerces(slotnames, opts = {}) opts = opts.stringify_keys raise ArgumentError, "coerces should have :to specified" unless opts['to'] check_condition(opts['if']) if opts['if'] check_condition(opts['unless']) if opts['unless'] slotnames = [slotnames] unless slotnames.is_a?(Array) slotnames.each {|slotname| register_coercion(slotname, opts)} end |