Class: SafetyPin::Query
- Inherits:
-
Object
- Object
- SafetyPin::Query
- Defined in:
- lib/safety_pin/query.rb,
lib/safety_pin/query/where_condition.rb
Defined Under Namespace
Classes: WhereCondition
Class Method Summary collapse
Instance Method Summary collapse
- #sql ⇒ Object
- #type(type) ⇒ Object
- #where(properties) ⇒ Object
- #where_conditions ⇒ Object
- #where_conditions=(where_conditions) ⇒ Object
- #within(path) ⇒ Object
Class Method Details
.execute(query_string) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/safety_pin/query.rb', line 3 def self.execute(query_string) query = query_manager.create_query(query_string, "JCR-SQL2") node_iter = query.execute.nodes nodes = [] while node_iter.has_next nodes << Node.new(node_iter.next_node) end nodes end |
Instance Method Details
#sql ⇒ Object
17 18 19 |
# File 'lib/safety_pin/query.rb', line 17 def sql [select_statement, where_statement].compact.join(" ") end |
#type(type) ⇒ Object
21 22 23 |
# File 'lib/safety_pin/query.rb', line 21 def type(type) @type = type end |
#where(properties) ⇒ Object
25 26 27 |
# File 'lib/safety_pin/query.rb', line 25 def where(properties) self.where_conditions = where_conditions + properties.map {|name, value| WhereCondition.new(name, value) } end |
#where_conditions ⇒ Object
38 39 40 |
# File 'lib/safety_pin/query.rb', line 38 def where_conditions @where_conditions ||= [] end |
#where_conditions=(where_conditions) ⇒ Object
42 43 44 |
# File 'lib/safety_pin/query.rb', line 42 def where_conditions=(where_conditions) @where_conditions = where_conditions end |
#within(path) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/safety_pin/query.rb', line 29 def within(path) @within ||= [] if path.is_a? String @within << path elsif path.is_a? Array @within += path end end |