Class: Moon::Action::Model::Show

Inherits:
Object
  • Object
show all
Defined in:
lib/moon/action/model/show.rb

Overview

Common model show action

Instance Method Summary collapse

Constructor Details

#initialize(model_key) ⇒ Show

Returns a new instance of Show.



5
6
7
# File 'lib/moon/action/model/show.rb', line 5

def initialize(model_key)
  @model_key = model_key
end

Instance Method Details

#perform(context) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/moon/action/model/show.rb', line 9

def perform(context)
  model = context.models[@model_key]
  if model
    Moon::Response::JSON::Model.new @model_key, context.models[@model_key], context.application.configuration.formatters
  else
    Moon::Response::JSON::Message.new 404, "Model not found."
  end
end