Module: CanTango::Macros::Permit

Extended by:
Permit::Helper::Naming
Included in:
Class
Defined in:
lib/cantango/permits_ext/macros/permit.rb

Instance Method Summary collapse

Methods included from Permit::Helper::Naming

account_name, permit_name, permit_type

Instance Method Details

#tango_permit(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cantango/permits_ext/macros/permit.rb', line 9

def tango_permit options = {}
  name = options[:name] || CanTango::Macros::Permit.permit_name(self)
   = options[:account] || CanTango::Macros::Permit.(self)
  super_class = self.superclass
  class_type = unless super_class == Object
    super_class.respond_to?(:type) ? super_class.type : nil
  end
  type = options[:type] || class_type

  raise CanTango::Permit::MissingNameError, "Name of permit could not be determined, try specifying a :name option" if name.nil?
  raise CanTango::Permit::MissingTypeError, "Type of permit could not be determined, try specifying a :type option" if type.nil?

  reg_options = {:name => name, :type => type, :account => }
  CanTango.config.permits.register self, reg_options
  reg_options
end