Module: Mongosteen::Actions

Defined in:
lib/mongosteen/actions.rb

Instance Method Summary collapse

Instance Method Details

#create(options = {}, &block) ⇒ Object

POST /resources



19
20
21
22
23
24
# File 'lib/mongosteen/actions.rb', line 19

def create(options={}, &block)
  super do |success, failure|
    success.json { render json: get_resource_ivar.as_json(json_config(:create)) }
    failure.json { render json: get_resource_ivar.errors, status: :unprocessable_entity }
  end
end

#index(options = {}, &block) ⇒ Object

GET /resources



4
5
6
7
8
9
# File 'lib/mongosteen/actions.rb', line 4

def index(options={}, &block)
  super do |success, failure|
    success.json { render json: get_collection_ivar.as_json(json_config(:index)) }
    success.csv  { render csv:  get_collection_ivar }
  end
end

#show(options = {}, &block) ⇒ Object

GET /resources/1



12
13
14
15
16
# File 'lib/mongosteen/actions.rb', line 12

def show(options={}, &block)
  super do |success, failure|
    success.json { render json: get_resource_version.as_json(json_config(:show)) }
  end
end

#update(options = {}, &block) ⇒ Object

PUT /resources/1



27
28
29
30
31
32
# File 'lib/mongosteen/actions.rb', line 27

def update(options={}, &block)
  super do |success, failure|
    success.json { render json: get_resource_ivar.as_json(json_config(:update)) }
    failure.json { render json: get_resource_ivar.errors, status: :unprocessable_entity }
  end
end