Class: Cog::DSL::SeedDSL
- Inherits:
-
Object
- Object
- Cog::DSL::SeedDSL
- Defined in:
- lib/cog/dsl/seed_dsl.rb
Overview
DSL for defining cog seeds
Instance Attribute Summary collapse
-
#seed ⇒ Cog::Seed
readonly
The seed which is defined by this DSL object.
Instance Method Summary collapse
- #constructor(&block) ⇒ Object
- #destructor(&block) ⇒ Object
-
#feature(name, opt = {}) {|f| ... } ⇒ nil
Define a new feature for this seed.
-
#in_scope(name) ⇒ nil
Place classes generated by this seed in the given scope.
-
#initialize(name) ⇒ SeedDSL
constructor
A new instance of SeedDSL.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
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 44 45 46 47 48 |
# File 'lib/cog/dsl/seed_dsl.rb', line 33 def method_missing(meth, *args, &block) meth = meth.to_s if meth.end_with? '_feature' opt = args.last.is_a?(Hash) ? args.pop : {} if /(?:\b|_)(public|protected|private)(?:\b|_)/ =~ meth opt[:access] = $1.to_sym end if /(?:\b|_)(abstract|virtual)(?:\b|_)/ =~ meth opt[$1.to_sym] = true end args << opt feature(*args, &block) else super end end |
Instance Attribute Details
#seed ⇒ Cog::Seed (readonly)
Returns the seed which is defined by this DSL object.
9 10 11 |
# File 'lib/cog/dsl/seed_dsl.rb', line 9 def seed @seed end |
Instance Method Details
#constructor(&block) ⇒ Object
24 25 26 |
# File 'lib/cog/dsl/seed_dsl.rb', line 24 def constructor(&block) feature :constructor, &block end |
#destructor(&block) ⇒ Object
28 29 30 |
# File 'lib/cog/dsl/seed_dsl.rb', line 28 def destructor(&block) feature :destructor, &block end |
#feature(name, opt = {}) {|f| ... } ⇒ nil
Define a new feature for this seed
57 58 59 60 61 62 63 |
# File 'lib/cog/dsl/seed_dsl.rb', line 57 def feature(name, opt={}, &block) dsl = FeatureDSL.new @seed, name, opt block.call dsl unless block.nil? f = dsl.feature seed_eval { @features << f } nil end |
#in_scope(name) ⇒ nil
Place classes generated by this seed in the given scope
19 20 21 22 |
# File 'lib/cog/dsl/seed_dsl.rb', line 19 def in_scope(name) seed_eval { @in_scope = name.to_s } nil end |