Sha256: f861604093237fe3be6a2e8d8460f95310cb02c303263533b8f2817baa063913
Contents?: true
Size: 1.9 KB
Versions: 7
Compression:
Stored size: 1.9 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?('@location') respond_with(instance_variable_get('@responder'), :location => instance_variable_get('@location')) 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?('@location') respond_with(instance_variable_get('@responder'), :location => instance_variable_get('@location')) else respond_with(instance_variable_get('@responder')) end end def destroy initialize_object delete(params[:id]) if instance_variable_defined?('@location') respond_with(instance_variable_get('@responder'), :location => instance_variable_get('@location')) 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
7 entries across 7 versions & 1 rubygems