Module: Sinicum::Jcr::NodeQueries::ClassMethods
- Includes:
- ApiClient, QuerySanitizer, Logger
- Defined in:
- lib/sinicum/jcr/node_queries.rb
Instance Method Summary collapse
- #find_by_path(workspace, path) ⇒ Object
- #find_by_uuid(workspace, uuid) ⇒ Object
- #query(workspace, language, query, parameters = nil, options = {}) ⇒ Object
- #stream_attribute(workspace, path, property_name, output) ⇒ Object
Methods included from ApiClient
Methods included from Logger
Instance Method Details
#find_by_path(workspace, path) ⇒ Object
16 17 18 19 |
# File 'lib/sinicum/jcr/node_queries.rb', line 16 def find_by_path(workspace, path) url = construct_url(workspace, nil, path) return_first_item(url) end |
#find_by_uuid(workspace, uuid) ⇒ Object
21 22 23 24 |
# File 'lib/sinicum/jcr/node_queries.rb', line 21 def find_by_uuid(workspace, uuid) url = construct_url(workspace, UUID_PREFIX, uuid) return_first_item(url) end |
#query(workspace, language, query, parameters = nil, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/sinicum/jcr/node_queries.rb', line 26 def query(workspace, language, query, parameters = nil, = {}) url = "/#{workspace}/_query" sanitized = sanitize_query(language, query, parameters) api_hash = { "query" => sanitized, "language" => language.to_s } api_hash["limit"] = [:limit] if [:limit] api_hash["offset"] = [:offset] if [:offset] response = api_get(url, api_hash) from_rest_response(response) end |
#stream_attribute(workspace, path, property_name, output) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/sinicum/jcr/node_queries.rb', line 36 def stream_attribute(workspace, path, property_name, output) connection = ApiQueries.http_client.get_async( ApiQueries.jcr_configuration.base_url + construct_url(workspace, BINARY_PREFIX, path), "property" => property_name) response = connection.pop while result = response.content.read(256) output.write(result) end end |