module Mongosteen::Actions

Public Instance Methods

create(options={}, &block) click to toggle source

POST /resources

Calls superclass method
# 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) click to toggle source

GET /resources

Calls superclass method
# 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) click to toggle source

GET /resources/1

Calls superclass method
# 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) click to toggle source

PUT /resources/1

Calls superclass method
# 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

Private Instance Methods

json_config(action) click to toggle source

Action options are: :index, :show, :create, :update

# File lib/mongosteen/actions.rb, line 37
def json_config(action)
  if action && as_json_config_actions.has_key?(action)
    as_json_config_actions[action]
  else
    as_json_config
  end
end