Module: Eipiai::CollectionResource

Defined in:
lib/eipiai/webmachine/resources/collection.rb

Overview

CollectionResource

The collection resource is the basis for a resource representing a collection of objects.

It provides basic GET and POST support.

It is the collection version of the ‘SingularResource` resource.

Instance Method Summary collapse

Instance Method Details

#allowed_methodsObject



14
15
16
# File 'lib/eipiai/webmachine/resources/collection.rb', line 14

def allowed_methods
  %w(GET POST)
end

#create_pathObject



22
23
24
# File 'lib/eipiai/webmachine/resources/collection.rb', line 22

def create_path
  singular_representer_class.new(new_object).path
end

#from_jsonObject



26
27
28
# File 'lib/eipiai/webmachine/resources/collection.rb', line 26

def from_json
  new_object.save && handle_post_response
end

#post_is_create?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/eipiai/webmachine/resources/collection.rb', line 18

def post_is_create?
  true
end