Module: BEL::DSL
- Defined in:
- lib/bel/dsl.rb
Overview
DSL adds BEL functions and relationships as Ruby methods that allows creation of BELParser::Expression::Model::Term and BELParser::Expression::Model::Statement objects.
DSL is an acronym for “Domain-specific language”.
Class Method Summary collapse
-
.include_in(object, spec) ⇒ Object
Defines ruby methods for BEL functions and relationships on object.
-
.included(another_module) ⇒ Object
Defines ruby methods for BEL functions and relationships on
another_module
.
Class Method Details
.include_in(object, spec) ⇒ Object
Defines ruby methods for BEL functions and relationships on object. The functions and relationships from the provided specification are used.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bel/dsl.rb', line 44 def self.include_in(object, spec) if [Class, Module].none? { |type| object.is_a?(type) } raise(ArgumentError, "object: expected Class or Module, actual #{object}") end BELParser::Resources.included(object) spec.functions.each do |function| self.send(:_define_term_method, object, function.short, function, spec) self.send(:_define_term_method, object, function.long, function, spec) end nil end |
.included(another_module) ⇒ Object
Defines ruby methods for BEL functions and relationships on another_module
. The functions and relationships from the default specification are included.
This method is called when BEL::DSL is included, as in:
# calls this method
include BEL::DSL
# Can access namespace constants.
HGNC
# Create new terms.
p(HGNC['AKT1'])
# Create new statements.
p(HGNC['AKT1']).increases bp(GOBP['apoptotic process'])
33 34 35 36 37 |
# File 'lib/bel/dsl.rb', line 33 def self.included(another_module) self.include_in( another_module, BELParser::Language.default_specification) end |