Sha256: b640ffe99206cd70437b59463ddfa44c3a9a251b02fa675737cf3c3a92c0195f

Contents?: true

Size: 358 Bytes

Versions: 1

Compression:

Stored size: 358 Bytes

Contents

module Structor
  class Builder
    attr_accessor :nodes

    def initialize(&block)
      @nodes = {}
      instance_eval(&block)
    end

    def requires(name, type = :hash, &block)
      @nodes[name] = Node.new(type, true, &block)
    end

    def optional(name, type = :hash, &block)
      @nodes[name] = Node.new(type, false, &block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
structor-0.0.1 lib/structor/builder.rb