Class: Whisperer::BaseDsl
- Inherits:
-
Object
- Object
- Whisperer::BaseDsl
- Defined in:
- lib/whisperer/dsl/base.rb
Direct Known Subclasses
Dsl, Dsl::Body, Dsl::Headers, Dsl::Request, Dsl::Response, Dsl::Status
Class Attribute Summary collapse
-
.container_class ⇒ Object
readonly
Returns the value of attribute container_class.
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
Class Method Summary collapse
- .add_writer(name) ⇒ Object
- .build ⇒ Object
- .link_container_class(val) ⇒ Object
- .link_dsl(name) ⇒ Object
Instance Method Summary collapse
-
#initialize(container) ⇒ BaseDsl
constructor
A new instance of BaseDsl.
Constructor Details
#initialize(container) ⇒ BaseDsl
Returns a new instance of BaseDsl.
43 44 45 |
# File 'lib/whisperer/dsl/base.rb', line 43 def initialize(container) @container = container end |
Class Attribute Details
.container_class ⇒ Object (readonly)
Returns the value of attribute container_class.
4 5 6 |
# File 'lib/whisperer/dsl/base.rb', line 4 def container_class @container_class end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
41 42 43 |
# File 'lib/whisperer/dsl/base.rb', line 41 def container @container end |
Class Method Details
.add_writer(name) ⇒ Object
34 35 36 37 38 |
# File 'lib/whisperer/dsl/base.rb', line 34 def add_writer(name) define_method(name) do |val| @container.public_send("#{name}=", val) end end |
.build ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/whisperer/dsl/base.rb', line 22 def build if self.container_class new( self.container_class.new ) else raise ArgumentError.new( 'You should associate a container (model) with this dsl class, before building it' ) end end |
.link_container_class(val) ⇒ Object
18 19 20 |
# File 'lib/whisperer/dsl/base.rb', line 18 def link_container_class(val) @container_class = val end |