Class: Hekenga::DSL
- Inherits:
-
Object
show all
- Defined in:
- lib/hekenga/dsl.rb,
lib/hekenga/dsl/migration.rb,
lib/hekenga/dsl/simple_task.rb,
lib/hekenga/dsl/document_task.rb
Defined Under Namespace
Classes: DocumentTask, Migration, SimpleTask
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(description = nil, &block) ⇒ DSL
Returns a new instance of DSL.
4
5
6
7
8
9
|
# File 'lib/hekenga/dsl.rb', line 4
def initialize(description = nil, &block)
@object = self.class.build_klass&.new
description(description) if description
instance_exec(&block)
@object.validate! if @object.respond_to?(:validate!)
end
|
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
3
4
5
|
# File 'lib/hekenga/dsl.rb', line 3
def object
@object
end
|
Class Method Details
.build_klass ⇒ Object
19
20
21
|
# File 'lib/hekenga/dsl.rb', line 19
def self.build_klass
@build_klass
end
|
16
17
18
|
# File 'lib/hekenga/dsl.rb', line 16
def self.configures(klass)
@build_klass = klass
end
|
Instance Method Details
#description(desc = nil) ⇒ Object
10
11
12
|
# File 'lib/hekenga/dsl.rb', line 10
def description(desc = nil)
@object.description = desc if @object && desc
end
|
#inspect ⇒ Object
13
14
15
|
# File 'lib/hekenga/dsl.rb', line 13
def inspect
"<#{self.class} - #{self.description}>"
end
|