Module: Interface::DSL
- Included in:
- PortGroup
- Defined in:
- lib/interface/dsl.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/interface/dsl.rb', line 33
def method_missing(meth, *args, &block)
super unless respond_to?(:interfaces) || respond_to?(:points)
if interfaces.respond_to?(meth)
interfaces.send(meth)
elsif points.respond_to?(meth)
points.send(meth)
else
super
end
end
|
Instance Method Details
#_interface_adapter ⇒ Object
68
69
70
|
# File 'lib/interface/dsl.rb', line 68
def _interface_adapter
@result_adapter || _settings.config.response_adapter
end
|
#defpoint(_name, &block) ⇒ Object
27
28
29
30
31
|
# File 'lib/interface/dsl.rb', line 27
def defpoint(_name, &block)
check_top_level_enpoint_policy
points.merge!(_name => define_entity(_name, &block))
end
|
#defsettings(configuration_class) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/interface/dsl.rb', line 5
def defsettings(configuration_class)
if !configuration_class.is_a?(Class) || !configuration_class.is_a?(Module)
fail(::Interface::Errors::UnexpectedInstanceError.new('Only classes and modules are supported'))
end
@settings ||= configuration_class
end
|
#doc ⇒ Object
53
54
55
56
57
58
|
# File 'lib/interface/dsl.rb', line 53
def doc
_name = self.respond_to?(:name) ? self.name : self.class.name
puts _name
doc_all_endpoints
interfaces.each_pair { |_, i| i.doc }
end
|
#extend_api(as:, with_class:) ⇒ Object
extend_api(as: ‘northbound.operations.truck_load’, with_class: TruckLoadAPI)
46
47
48
49
50
51
|
# File 'lib/interface/dsl.rb', line 46
def extend_api(as: , with_class: )
_merge_point = respond_to?(:points) ? points : self
_merge_point.merge!(as => with_class)
end
|
#interface(name, &block) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/interface/dsl.rb', line 17
def interface(name, &block)
if interfaces.key?(name)
fail(::Interface::Errors::ImmutableInterfaceError.new("Interface can't be redefined or reopened! Use .extend_api method"))
end
interfaces.merge!(name => ::Interface::PortGroup.new(name, self).tap do |group|
group.instance_eval(&block)
end)
end
|
#interfaces ⇒ Object
60
61
62
|
# File 'lib/interface/dsl.rb', line 60
def interfaces
@interfaces ||= Hashie::Mash.new
end
|
#points ⇒ Object
64
65
66
|
# File 'lib/interface/dsl.rb', line 64
def points
@points ||= Hashie::Mash.new
end
|
#returns(result_adapter) ⇒ Object
13
14
15
|
# File 'lib/interface/dsl.rb', line 13
def returns(result_adapter)
@result_adapter = result_adapter
end
|