Method: Atomsphere.query

Defined in:
lib/atomsphere/query/builder.rb

.query(object_type = nil, &block) ⇒ Object

Invoke the DSL for constructing an Query

Examples:

without an expression, returns all possible results

Atomsphere.query(:process)

a simple query expression for online Atoms

Atomsphere.query(:atom) { status.equals :online }

a query expression for online cloud Atoms (implied ‘and` group)

Atomsphere.query(:atom) do
  status.equals :online
  type.equals :cloud
end

a more complex example with nested group expressions

Atomsphere.query(:atom) do
  group :or do
    date_installed.less_than '2018-12-01T00:00:00Z'
    group :and do
      status.not_equals :online
      type.not_equals :cloud
    end
  end
end


64
65
66
67
68
69
# File 'lib/atomsphere/query/builder.rb', line 64

def self.query(object_type=nil, &block)
  q = Query::Builder.new(object_type)
  q.instance_eval(&block) if block_given?

  q.query
end