Sha256: 5af43755d43afd30d7f21a304b8de87588807fb91cbb35e72e98c6f1af503171
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'action_controller' module Zertico class Controller < ActionController::Base def initialize begin extend "::#{self.class.name.chomp("Controller").concat("Service")}".constantize rescue NameError extend Zertico::Service end super end def index initialize_object all end def new initialize_object build end def show initialize_object find(params[:id]) end def edit initialize_object find(params[:id]) end def create initialize_object generate(params[interface_name.to_sym]) respond_with(instance_variable_get(@object_name)) end def update initialize_object modify(params[:id], params[interface_name.to_sym]) respond_with(instance_variable_get(@object_name)) end def destroy initialize_object delete(params[:id]) respond_with(instance_variable_get(@object_name)) end protected def initialize_object(object = {}) object.each do |key, value| @object_name = "@#{key}" instance_variable_set(@object_name, value) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zertico-0.3.1 | lib/zertico/controller.rb |
zertico-0.3.0 | lib/zertico/controller.rb |