Module: Gizmo

Defined in:
lib/gizmo.rb,
lib/gizmo/aop.rb,
lib/gizmo/find.rb,
lib/gizmo/make.rb,
lib/gizmo/delete.rb,
lib/gizmo/models.rb,
lib/gizmo/modify.rb,
lib/gizmo/search.rb,
lib/gizmo/version.rb,
lib/gizmo/find_all.rb,
lib/gizmo/models/error.rb,
lib/gizmo/base_operation.rb,
lib/gizmo/models/context.rb,
lib/gizmo/models/response.rb,
lib/gizmo/aop/exception_handling.rb,
lib/gizmo/models/validation_error.rb

Defined Under Namespace

Classes: BaseOperation, Context, Delete, Error, ExceptionHandling, Find, FindAll, Make, Modify, Response, Search, ValidationError

Constant Summary collapse

VERSION =
"0.0.2"

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



19
20
21
# File 'lib/gizmo.rb', line 19

def logger
  @logger
end

Instance Method Details

#delete(*args) ⇒ Gizmo::Response

Delete an item

Parameters:

  • criteria (Mongoid::Criteria)
  • id (String, Moped::BSON::ObjecId)

Returns:



83
84
85
86
# File 'lib/gizmo.rb', line 83

def delete(*args)
  context = create_context
  Delete.new(context).call(*args)
end

#find(*args) ⇒ Gizmo::Response

Find an item

Parameters:

  • criteria (Mongoid::Criteria)
  • id (String, Moped::BSON::ObjecId)

Returns:



41
42
43
44
# File 'lib/gizmo.rb', line 41

def find(*args)
  context = create_context
  Find.new(context).call(*args)
end

#find_all(*args) ⇒ Gizmo::Response

Find all items

Parameters:

  • criteria (Mongoid::Criteria)

Returns:



27
28
29
30
31
32
33
# File 'lib/gizmo.rb', line 27

def find_all(*args)
  context = create_context
  operation = FindAll.new(context)
  response = operation.call(*args)
  operation.set_response_headers response
  response
end

#make(*args) ⇒ Gizmo::Response

Make a new instance of an item

Parameters:

  • criteria (Mongoid::Criteria)
  • attrs (Hash)

Returns:



57
58
59
60
61
62
63
# File 'lib/gizmo.rb', line 57

def make(*args)
  context = create_context
  operation = Make.new(context)
  response = operation.call(*args)
  operation.set_response_headers response
  response
end

#modify(*args) ⇒ Gizmo::Response

Modify an item

Parameters:

  • criteria (Mongoid::Criteria)
  • id (String, Moped::BSON::ObjecId)
  • attrs (Hash)

Returns:



72
73
74
75
# File 'lib/gizmo.rb', line 72

def modify(*args)
  context = create_context
  Modify.new(context).call(*args)
end

#search(*args) ⇒ Object



46
47
48
49
# File 'lib/gizmo.rb', line 46

def search(*args)
  context = create_context
  Search.new(context).call(*args)
end