Class: Structor::Builder
- Inherits:
-
Object
- Object
- Structor::Builder
- Defined in:
- lib/structor/builder.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
- #optional(name, type = :hash, &block) ⇒ Object
- #requires(name, type = :hash, &block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Builder
Returns a new instance of Builder.
5 6 7 8 |
# File 'lib/structor/builder.rb', line 5 def initialize(&block) @nodes = {} instance_eval(&block) end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
3 4 5 |
# File 'lib/structor/builder.rb', line 3 def nodes @nodes end |
Instance Method Details
#optional(name, type = :hash, &block) ⇒ Object
14 15 16 |
# File 'lib/structor/builder.rb', line 14 def optional(name, type = :hash, &block) @nodes[name] = Node.new(type, false, &block) end |
#requires(name, type = :hash, &block) ⇒ Object
10 11 12 |
# File 'lib/structor/builder.rb', line 10 def requires(name, type = :hash, &block) @nodes[name] = Node.new(type, true, &block) end |