Class: Monark::DSL
Overview
The Monark DSL.
Instance Attribute Summary collapse
-
#_context ⇒ Object
readonly
Returns the value of attribute _context.
Instance Method Summary collapse
- #add(name, options = {}, &block) ⇒ Object
- #groups(*args, &block) ⇒ Object (also: #group)
-
#initialize(context = nil) ⇒ DSL
constructor
A new instance of DSL.
- #load(name, options = {}, &block) ⇒ Object
- #set_version(arg) ⇒ Object
Constructor Details
#initialize(context = nil) ⇒ DSL
Returns a new instance of DSL.
9 10 11 |
# File 'lib/monark/dsl.rb', line 9 def initialize(context = nil) @_context = context end |
Instance Attribute Details
#_context ⇒ Object (readonly)
Returns the value of attribute _context.
7 8 9 |
# File 'lib/monark/dsl.rb', line 7 def _context @_context end |
Instance Method Details
#add(name, options = {}, &block) ⇒ Object
23 24 25 26 27 |
# File 'lib/monark/dsl.rb', line 23 def add(name, = {}, &block) groups(.fetch(:group, [:groups])) do _context.push Migration.new(_context.root, name, block) end end |
#groups(*args, &block) ⇒ Object Also known as: group
13 14 15 16 |
# File 'lib/monark/dsl.rb', line 13 def groups(*args, &block) groups = args.flatten.compact yield if groups.empty? || groups.include?(_context.env.to_sym) end |
#load(name, options = {}, &block) ⇒ Object
29 30 31 32 |
# File 'lib/monark/dsl.rb', line 29 def load(name, = {}, &block) add(name, , &block) _context.migrations.last.reloadable = true end |
#set_version(arg) ⇒ Object
19 20 21 |
# File 'lib/monark/dsl.rb', line 19 def set_version(arg) _context.version = arg end |