Class: Hecks::Bluebook::DSL::PortBuilder

Inherits:
Object
  • Object
show all
Includes:
WordGate
Defined in:
lib/hecks/bluebook/dsl/port_builder.rb

Constant Summary collapse

GRAMMAR_CONTEXT =
"Port"

Constants included from WordGate

WordGate::NOT_ADMITTED

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ PortBuilder

Returns a new instance of PortBuilder.



10
11
12
13
14
# File 'lib/hecks/bluebook/dsl/port_builder.rb', line 10

def initialize(name)
  @name    = name
  @signal  = :reply
  @answers = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hecks::Bluebook::DSL::WordGate

Class Method Details

.build(name, &block) ⇒ Object



31
32
33
34
35
# File 'lib/hecks/bluebook/dsl/port_builder.rb', line 31

def self.build(name, &block)
  builder = new(name)
  builder.instance_eval(&block) if block
  builder.build
end

Instance Method Details

#answers(name) ⇒ Object

THE METHOD CONTRACT — the fact a .port file's verb/signal never carried: what an adapter must actually RESPOND TO for a dispatch to reach it without a bare NoMethodError. Declared the same repeatable way AdapterBuilder#field/#secret already are, so verify! can check it with respond_to? at boot instead of the runtime discovering it live.



25
# File 'lib/hecks/bluebook/dsl/port_builder.rb', line 25

def answers(name) = @answers << name.to_sym

#buildObject



27
28
29
# File 'lib/hecks/bluebook/dsl/port_builder.rb', line 27

def build
  MetaValidator.call_port(Port.new(name: @name, verb: @verb, signal: @signal, answers: @answers))
end

#signal(value) ⇒ Object



17
# File 'lib/hecks/bluebook/dsl/port_builder.rb', line 17

def signal(value) = @signal = value.to_sym

#verb(value) ⇒ Object



16
# File 'lib/hecks/bluebook/dsl/port_builder.rb', line 16

def verb(value)   = @verb = value.to_s