Class: CanTango::Config::User
- Inherits:
-
Object
- Object
- CanTango::Config::User
- Includes:
- ClassExt, Singleton
- Defined in:
- lib/cantango/config/user.rb
Instance Method Summary collapse
- #base_class ⇒ Object
- #base_class=(clazz) ⇒ Object
- #clear! ⇒ Object
- #default_relations ⇒ Object
- #relations ⇒ Object
- #relations=(*relations) ⇒ Object
- #unique_key_field ⇒ Object
- #unique_key_field=(key) ⇒ Object
Instance Method Details
#base_class ⇒ Object
14 15 16 |
# File 'lib/cantango/config/user.rb', line 14 def base_class @clazz ||= (::User if defined? ::User) end |
#base_class=(clazz) ⇒ Object
18 19 20 21 |
# File 'lib/cantango/config/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/config/user.rb', line 8 def clear! @clazz = nil @unique_key_field = nil @relations = nil end |
#default_relations ⇒ Object
40 41 42 |
# File 'lib/cantango/config/user.rb', line 40 def default_relations [:owner, :author, :writer, :user] end |
#relations ⇒ Object
36 37 38 |
# File 'lib/cantango/config/user.rb', line 36 def relations @relations ||= default_relations end |
#relations=(*relations) ⇒ Object
32 33 34 |
# File 'lib/cantango/config/user.rb', line 32 def relations= *relations @relations = relations.select_labels end |
#unique_key_field ⇒ Object
23 24 25 |
# File 'lib/cantango/config/user.rb', line 23 def unique_key_field @unique_key_field || :email end |
#unique_key_field=(key) ⇒ Object
27 28 29 30 |
# File 'lib/cantango/config/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 |