Module: RTM::TMQL::Queryable
- Defined in:
- lib/rtm/tmql.rb
Instance Method Summary collapse
-
#execute_tmql(query, params = {}) ⇒ Object
(also: #tmql)
Runs a query on a TMQL engine.
-
#initialize_tmql_engine(params = {}) ⇒ Object
Initializes a TMQL engine and returns it.
-
#tmql_engine(params = {}) ⇒ Object
Initialize a TMQL engine or gives back an existing one.
- #tmql_version ⇒ Object
Instance Method Details
#execute_tmql(query, params = {}) ⇒ Object Also known as: tmql
Runs a query on a TMQL engine. Initializes the default engine, if not done before.
18 19 20 21 22 23 24 25 |
# File 'lib/rtm/tmql.rb', line 18 def execute_tmql(query, params={}) raise("query should be a String and params should be a Hash") unless(query.is_a?(String) && params.is_a?(Hash)) if params.empty? return tmql_engine.execute(query) else return tmql_engine(params).execute(query) end end |
#initialize_tmql_engine(params = {}) ⇒ Object
Initializes a TMQL engine and returns it
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rtm/tmql.rb', line 35 def initialize_tmql_engine(params={}) if self.read_only? unless params[:environment_map] env_map = self.tmql_environment_map raise("you need to define an environment map for this read-only topic map, e.g. topic_map.initialize_tmql_engine(:environment_map => env_map).") unless env_map.is_a?(RTM::TopicMap) end @tmql_engine = RTM::TMQL::Engine.create(self, {:environment_map => env_map}.merge(params)) else @tmql_engine = TMQL::Engine.create(self, params) end @tmql_engine end |
#tmql_engine(params = {}) ⇒ Object
Initialize a TMQL engine or gives back an existing one
29 30 31 32 |
# File 'lib/rtm/tmql.rb', line 29 def tmql_engine(params={}) raise("params should be a Hash") unless params.is_a?(Hash) @tmql_engine || initialize_tmql_engine(params) end |
#tmql_version ⇒ Object
48 49 50 |
# File 'lib/rtm/tmql.rb', line 48 def tmql_version return TMQL4JEngine.version end |