Class: Brandish::Configure::DSL::Form
- Inherits:
-
Object
- Object
- Brandish::Configure::DSL::Form
- Defined in:
- lib/brandish/configure/dsl/form.rb
Overview
Constructs a form for use with the configure instance. A form is basically a format and name pair; different forms can have different entries, formats, and processors.
Instance Attribute Summary collapse
-
#entry ⇒ ::String
writeonly
The entry for the form.
-
#name ⇒ ::String
writeonly
The name of the form.
Instance Method Summary collapse
-
#data ⇒ (::String, ::Symbol, ::String, <(::String, ::String, ::Hash)>]
The data from this form.
-
#initialize(format, name = nil) ⇒ Form
constructor
Initialize the form DSL.
-
#use(*arguments) ⇒ void
(also: #process, #processor, #define)
Adds a processor for use for the form.
Constructor Details
#initialize(format, name = nil) ⇒ Form
Initialize the form DSL. This sets up the initial format and name, and intializes the instance variables.
28 29 30 31 32 33 |
# File 'lib/brandish/configure/dsl/form.rb', line 28 def initialize(format, name = nil) @name = name || _generate_form_name @format = format @entry = "index.br" @processors = [] end |
Instance Attribute Details
#entry=(value) ⇒ ::String (writeonly)
The entry for the form. This is the file that begins the parsing for the form.
21 22 23 |
# File 'lib/brandish/configure/dsl/form.rb', line 21 def entry=(value) @entry = value end |
#name=(value) ⇒ ::String (writeonly)
The name of the form. This defaults to a random value. Do not rely on the name unless it is set.
15 16 17 |
# File 'lib/brandish/configure/dsl/form.rb', line 15 def name=(value) @name = value end |
Instance Method Details
#data ⇒ (::String, ::Symbol, ::String, <(::String, ::String, ::Hash)>]
The data from this form. This is used to create the actual form that is used in the configuration.
90 91 92 |
# File 'lib/brandish/configure/dsl/form.rb', line 90 def data [@name, @format, @entry, @processors] end |
#use(name, options = {}) ⇒ void #use(options = {}) { ... } ⇒ void Also known as: process, processor, define
This method returns an undefined value.
Adds a processor for use for the form. The order that this is called is important.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/brandish/configure/dsl/form.rb', line 68 def use(*arguments) processor = = nil if block_given? = arguments[0] processor = Class.new(Brandish::Processor::Base, &::Proc.new) else name = arguments[0] = arguments[1] processor = _guess_processor_name(name) end @processors << [processor, || {}] end |