Sha256: 3d82b030bf3587598e61fd59c5a7cf541cb022c42c31c91d153b3e48f36be333
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 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 respond_with(instance_variable_get('@responder')) end def new initialize_object build respond_with(instance_variable_get('@responder')) end def show initialize_object find(params[:id]) respond_with(instance_variable_get('@responder')) end def edit initialize_object find(params[:id]) respond_with(instance_variable_get('@responder')) end def create initialize_object generate(params[interface_name.to_sym]) if instance_variable_defined?('@path') respond_with(instance_variable_get('@responder'), :path => instance_variable_get('@path')) else respond_with(instance_variable_get('@responder')) end end def update initialize_object modify(params[:id], params[interface_name.to_sym]) if instance_variable_defined?('@path') respond_with(instance_variable_get('@responder'), :path => instance_variable_get('@path')) else respond_with(instance_variable_get('@responder')) end end def destroy initialize_object delete(params[:id]) if instance_variable_defined?('@path') respond_with(instance_variable_get('@responder'), :path => instance_variable_get('@path')) else respond_with(instance_variable_get('@responder')) end end protected def initialize_object(objects = {}) objects.each do |key, value| instance_variable_set("@#{key}", value) instance_variable_set('@responder', value) unless @responder end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zertico-0.5.0 | lib/zertico/controller.rb |