Sha256: ca7a6cce51322becc47f08ebddc546fed4fa9aa1891bc2754a8ad5b16d4a752b
Contents?: true
Size: 976 Bytes
Versions: 1
Compression:
Stored size: 976 Bytes
Contents
require "batch_actions/version" require "batch_actions/class_methods" module BatchActions def batch_actions return [] unless self.class.instance_variable_defined? :@batch_actions actions = self.class.instance_variable_get :@batch_actions allowed = [] actions.each do |keyword, condition| if instance_exec(&condition) allowed << keyword end end allowed end def dispatch_batch name = params[:batch_action] allowed = batch_actions.detect { |action| action.to_s == name.to_s } unless allowed raise ActionController::RoutingError.new('batch action is not allowed') end self.status, headers, self.response_body = self.class.action(:"batch_#{name}").call(env) self.headers.merge! headers end def self.included(base) base.extend ClassMethods if defined?(InheritedResources::Base) && base < InheritedResources::Base base.batch_model base.resource_class end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
batch_actions-0.0.2 | lib/batch_actions.rb |