Class: Ixtlan::UserManagement::Domain

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/ixtlan/user_management/domain_resource.rb

Constant Summary collapse

ALL_ID =
1
DEFAULT_ID =
2
ALL_NAME =
'ALL'
DEFAULT_NAME =
'DEFAULT'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ALLObject



44
45
46
# File 'lib/ixtlan/user_management/domain_resource.rb', line 44

def self.ALL
  first_or_create( :id => ALL_ID, :name => ALL_NAME )
end

.almost_all(args = {}) ⇒ Object



52
53
54
# File 'lib/ixtlan/user_management/domain_resource.rb', line 52

def self.almost_all( args = {} )
  all( { :id.gt => ALL_ID }.merge( args ) )
end

.base_modelObject

key for selectng the IdentityMap should remain this class if there is no single table inheritance with Discriminator in place i.e. the subclass used as key for the IdentityMap



34
35
36
# File 'lib/ixtlan/user_management/domain_resource.rb', line 34

def self.base_model
  self
end

.DEFAULTObject



48
49
50
# File 'lib/ixtlan/user_management/domain_resource.rb', line 48

def self.DEFAULT
  first_or_create( :id => DEFAULT_ID, :name => DEFAULT_NAME )
end

.first_or_create(args) ⇒ Object



56
57
58
# File 'lib/ixtlan/user_management/domain_resource.rb', line 56

def self.first_or_create( args )
  first( args ) || create!( args.merge( {:updated_at => DateTime.new( 1 ) } ) )
end

.storage_name(arg) ⇒ Object



27
28
29
# File 'lib/ixtlan/user_management/domain_resource.rb', line 27

def self.storage_name(arg)
  'ixtlan_domains'
end

Instance Method Details

#all?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/ixtlan/user_management/domain_resource.rb', line 69

def all?
  name == ALL_NAME
end

#default?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/ixtlan/user_management/domain_resource.rb', line 73

def default?
  name == DEFAULT_NAME
end

#set_timestamps_on_saveObject

do not record timestamps since they are set from outside



66
67
# File 'lib/ixtlan/user_management/domain_resource.rb', line 66

def set_timestamps_on_save
end