Sha256: fb845cfd1b9b3fea842fff093b8fc30bf95741bd38a31d891763f646fbbaee08
Contents?: true
Size: 618 Bytes
Versions: 1
Compression:
Stored size: 618 Bytes
Contents
# frozen_string_literal: true module ActionMan module Model extend ActiveSupport::Concern module ClassMethods def action(action_name, class_name=nil) define_method(action_name) do |params| (class_name || self.class.action_class(action_name)).constantize.new(self).run(params) end define_method("#{action_name}?") do (class_name || self.class.action_class(action_name)).constantize.new(self).executable? end end def action_class(action_name) "#{name.pluralize}::#{action_name.to_s.camelcase}Action" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
action_man-0.0.1 | lib/action_man/model.rb |