<NME> rest_controller.rb
<BEF> # encoding: utf-8

require "rango/controller"

class RESTController < Controller
  def self.object_name=(object_name)

<MSG> Put to the Rango namespace

<DFF> @@ -1,94 +1,98 @@
 # encoding: utf-8
 
 require "rango/controller"
+require "rango/mixins/conventional_rendering"
 
-class RESTController < Controller
-  def self.object_name=(object_name)
-    @@object_name = object_name
-  end
+module Rango
+  class RESTController < Controller
+    include ConventionalRendering
+    def self.object_name=(object_name)
+      @@object_name = object_name
+    end
 
-  def self.object_name
-    @@object_name
-  rescue NameError
-    @@object_name = begin
-      name = self.class.name
-      name.split("::").last.snake_case
+    def self.object_name
+      @@object_name
+    rescue NameError
+      @@object_name = begin
+        name = self.class.name
+        name.split("::").last.snake_case
+      end
     end
-  end
 
-  # @api plugin
-  def object_name
-    self.class.object_name
-  end
+    # @api plugin
+    def object_name
+      self.class.object_name
+    end
 
-  def collection_name
-    @@collection_name ||= @@object_name.to_s.pluralize
-  end
+    def collection_name
+      @@collection_name ||= @@object_name.to_s.pluralize
+    end
 
-  def self.named_route=(named_route)
-    @@named_route = named_route
-  end
+    def self.named_route=(named_route)
+      @@named_route = named_route
+    end
 
-  def self.named_route
-    @@named_route
-  rescue NameError
-    @@named_route = begin
-      name = self.class.name
-      name.split("::").last.snake_case
+    def self.named_route
+      @@named_route
+    rescue NameError
+      @@named_route = begin
+        name = self.class.name
+        name.split("::").last.snake_case
+      end
     end
-  end
 
-  # @api plugin
-  def named_route
-    self.class.named_route
-  end
+    # @api plugin
+    def named_route
+      self.class.named_route
+    end
 
-  # CRUD methods
-  def index(&block)
-    raise ArgumentError, "You have to provide a block" if block.nil?
-    set_context_value(collection_name, block.call)
-    autorender
-  end
+    # CRUD methods
+    def index(&block)
+      raise ArgumentError, "You have to provide a block" if block.nil?
+      set_context_value(collection_name, block.call)
+      autorender
+    end
 
-  def show(&block)
-    raise ArgumentError, "You have to provide a block" if block.nil?
-    set_context_value(collection_name, block.call)
-    autorender
-  end
+    def show(&block)
+      raise ArgumentError, "You have to provide a block" if block.nil?
+      set_context_value(collection_name, block.call)
+      autorender
+    end
 
-  def new(&block)
-    raise ArgumentError, "You have to provide a block" if block.nil?
-    set_context_value(collection_name, block.call)
-    autorender
-  end
+    def new(&block)
+      raise ArgumentError, "You have to provide a block" if block.nil?
+      set_context_value(collection_name, block.call)
+      autorender
+    end
 
-  def edit(&block)
-    raise ArgumentError, "You have to provide a block" if block.nil?
-    set_context_value(collection_name, block.call)
-    autorender
-  end
+    def edit(&block)
+      raise ArgumentError, "You have to provide a block" if block.nil?
+      set_context_value(collection_name, block.call)
+      autorender
+    end
 
-  def create(notice = "Created successfully", error = "Can't create", &block)
-    raise ArgumentError, "You have to provide a block" if block.nil?
-    object = block.call
-    if object.save
-      message[:notice] = notice
-      redirect url(named_route, object)
-    else
-      message[:error] = error
-      render_relative "show"
+    def create(notice = "Created successfully", error = "Can't create", &block)
+      raise ArgumentError, "You have to provide a block" if block.nil?
+      object = block.call
+      if object.save
+        message[:notice] = notice
+        redirect url(named_route, object)
+      else
+        message[:error] = error
+        render_relative "show"
+      end
     end
-  end
 
-  def update(notice = "Updated successfully", error = "Can't update", &block)
-    raise ArgumentError, "You have to provide a block" if block.nil?
-    object = block.call
-    if object.save
-      message[:notice] = notice
-      redirect url(named_route, object)
-    else
-      message[:error] = error
-      render_relative "show"
+    def update(notice = "Updated successfully", error = "Can't update", &block)
+      raise ArgumentError, "You have to provide a block" if block.nil?
+      object = block.call
+      if object.save
+        message[:notice] = notice
+        redirect url(named_route, object)
+      else
+        message[:error] = error
+        render_relative "show"
+      end
     end
   end
 end

Put to the Rango namespace