Module: ActionPlugin::Mixin

Extended by:
ActiveSupport::Concern
Defined in:
lib/action_plugin/mixin.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#format_opts(opts) ⇒ Object



13
14
15
# File 'lib/action_plugin/mixin.rb', line 13

def format_opts opts
  opts.extract!(:subject_id, :subject_type, :action_type, :target_type, :target_id)
end

#validate_opts(opts = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/action_plugin/mixin.rb', line 5

def validate_opts opts = {}
  return false if opts[:subject].blank? || opts[:action_type].blank?
  return false if opts[:target_id].blank? || opts[:target_type].blank?
  opts[:subject_id]   = opts[:subject].id
  opts[:subject_type] = opts[:subject].class.name
  opts
end