Class: OntologyUnited::DSL::OntologyDSL

Inherits:
BaseDSL
  • Object
show all
Defined in:
lib/ontology-united/dsl/ontology_dsl.rb

Direct Known Subclasses

Ontology

Class Method Summary collapse

Methods inherited from BaseDSL

attr_reader_with_default, #establish_defaults

Methods included from Stack

#current, #parent, #stack

Methods included from Stack::Delegate

#delegate_stack_to

Class Method Details

.define(name, as: nil, &block) ⇒ Object



5
6
7
8
# File 'lib/ontology-united/dsl/ontology_dsl.rb', line 5

def self.define(name, as: nil, &block)
  ontology = Ontology.new(name)
  redefine(ontology, as: as, &block)
end

.redefine(ontology, as: nil, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ontology-united/dsl/ontology_dsl.rb', line 10

def self.redefine(ontology, as: nil, &block)
  stack.push(ontology)
  ontology.as(as) if as
  if block
    if block.arity == 1
      block.call(ontology)
    else
      ontology.instance_eval(&block)
    end
  end
  stack.pop
  ontology
end