Sha256: 2e750e027d146ccb744d94a29306def00807af44fad3b01184e27f68006f9732

Contents?: true

Size: 777 Bytes

Versions: 19

Compression:

Stored size: 777 Bytes

Contents

class Module
  def tango_permit options = {}
    name_from_class_name = CanTango::Permit.first_name self.to_s.split("::").last
    name = options[:name] || name_from_class_name

    account_from_class_name = CanTango::Permit.first_name self.to_s.split("::").first if (self.to_s.split("::").size > 1)
    account = options[:account] || account_from_class_name

    type = options[:type] || self.superclass.type

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

    CanTango.config.permits.register_permit_class name, self, type, account
    # return hash for debugging
    {:name => name, :type => type, :account => account}
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cantango-0.9.4.7 lib/cantango/permits/macros.rb
cantango-0.9.4.6 lib/cantango/permits/macros.rb
cantango-0.9.4.5 lib/cantango/permits/macros.rb
cantango-0.9.4.3 lib/cantango/permits/macros.rb
cantango-0.9.4.2 lib/cantango/permits/macros.rb
cantango-0.9.4.1 lib/cantango/permits/macros.rb
cantango-0.9.4 lib/cantango/permits/macros.rb
cantango-0.9.3.2 lib/cantango/permits/macros.rb
cantango-0.8.9.5 lib/cantango/permits/macros.rb
cantango-0.8.9.4 lib/cantango/permits/macros.rb
cantango-0.8.9.3 lib/cantango/permits/macros.rb
cantango-0.8.9.2 lib/cantango/permits/macros.rb
cantango-0.8.9.1 lib/cantango/permits/macros.rb
cantango-0.8.9 lib/cantango/permits/macros.rb
cantango-0.8.8.1 lib/cantango/permits/macros.rb
cantango-0.8.8 lib/cantango/permits/macros.rb
cantango-0.8.7 lib/cantango/permits/macros.rb
cantango-0.8.6.2 lib/cantango/permits/macros.rb
cantango-0.8.6.1 lib/cantango/permits/macros.rb