Class: CanTango::Configuration::User

Inherits:
Object
  • Object
show all
Includes:
ClassExt, Singleton
Defined in:
lib/cantango/configuration/user.rb

Instance Method Summary collapse

Instance Method Details

#base_classObject



14
15
16
# File 'lib/cantango/configuration/user.rb', line 14

def base_class
  @clazz ||= (::User if defined? ::User)
end

#base_class=(clazz) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
# File 'lib/cantango/configuration/user.rb', line 18

def base_class= clazz
  raise ArgumentError, "Must be a class, was: #{clazz}" unless is_class? clazz
  @clazz = clazz
end

#clear!Object



8
9
10
11
12
# File 'lib/cantango/configuration/user.rb', line 8

def clear!
  @clazz = nil
  @unique_key_field = nil
  @relations = nil
end

#default_relationsObject



40
41
42
# File 'lib/cantango/configuration/user.rb', line 40

def default_relations
  [:owner, :author, :writer, :user]
end

#relationsObject



36
37
38
# File 'lib/cantango/configuration/user.rb', line 36

def relations
  @relations ||= default_relations
end

#relations=(*relations) ⇒ Object



32
33
34
# File 'lib/cantango/configuration/user.rb', line 32

def relations= *relations
  @relations = relations.select_labels
end

#unique_key_fieldObject



23
24
25
# File 'lib/cantango/configuration/user.rb', line 23

def unique_key_field
  @unique_key_field || :email
end

#unique_key_field=(key) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
# File 'lib/cantango/configuration/user.rb', line 27

def unique_key_field= key
  raise ArgumentError, "Not a valid key" unless key.kind_of_label?
  @unique_key_field = key.to_sym
end