Module: DataMapper
- Defined in:
- lib/base/datamapper_l.rb
Defined Under Namespace
Modules: Migrations, Model, Resource Classes: Collection, GlobalMutex
Class Attribute Summary collapse
-
.lock ⇒ Object
readonly
Returns the value of attribute lock.
Class Method Summary collapse
- .initialize_lock_file(lock_file) ⇒ Object
-
.original_setup ⇒ Object
extend DataMapper.setup parameters for a new :lock_file options new setup can be called as following: DataMapper.setup(<name>, <String>, :lock_file => file) DataMapper.setup(<name>, <Addressable::URI>, :lock_file => file) DataMapper.setup(<name>, <other_connection_options, :lock_file => file>).
- .setup(*args) ⇒ Object
Class Attribute Details
.lock ⇒ Object (readonly)
Returns the value of attribute lock.
37 38 39 |
# File 'lib/base/datamapper_l.rb', line 37 def lock @lock end |
Class Method Details
.initialize_lock_file(lock_file) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/base/datamapper_l.rb', line 55 def initialize_lock_file(lock_file) FileUtils.mkdir_p(File.dirname(lock_file)) File.open(lock_file, 'w') do |file| file.truncate(0) end @lock = GlobalMutex.new(lock_file) end |
.original_setup ⇒ Object
extend DataMapper.setup parameters for a new :lock_file options new setup can be called as following: DataMapper.setup(<name>, <String>, :lock_file => file) DataMapper.setup(<name>, <Addressable::URI>, :lock_file => file) DataMapper.setup(<name>, <other_connection_options, :lock_file => file>)
44 |
# File 'lib/base/datamapper_l.rb', line 44 alias original_setup setup |
.setup(*args) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/base/datamapper_l.rb', line 45 def setup(*args) unless @lock lock_file = args[1][:lock_file] if args.size == 2 && args[1].kind_of?(Hash) lock_file = args[2][:lock_file] if args.size == 3 lock_file ||= '/var/vcap/sys/run/LOCK' initialize_lock_file(lock_file) end original_setup(*(args[0..1])) end |