Sha256: b4eb3d940a73f11b4c54861ebce85a7cedc3239d941326061a1a9c6b18a1d5f0
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.2.0 | lib/zertico/controller.rb |
zertico-0.1.3 | lib/zertico/controller.rb |