Module: Hyperactive::Record::Persistent::ClassMethods

Defined in:
lib/hyperactive/record.rb

Instance Method Summary collapse

Instance Method Details

#find(record_id, transaction = nil) ⇒ Object

Return the record with record_id, optionally within a transaction.



160
161
162
# File 'lib/hyperactive/record.rb', line 160

def find(record_id, transaction = nil)
  Archipelago::Pirate::BLACKBEARD[record_id, transaction]
end

#get_instance(*args) ⇒ Object

Utility method to get a proxy to a newly saved instance of this class in one call.



167
168
169
170
# File 'lib/hyperactive/record.rb', line 167

def get_instance(*args)
  instance = self.new(*args)
  return instance.create
end

#get_instance_with_transaction(transaction, *args) ⇒ Object

Utility method to get a proxy to a within a transaction newly saved instance of this class in one call.



148
149
150
151
152
153
154
155
# File 'lib/hyperactive/record.rb', line 148

def get_instance_with_transaction(transaction, *args)
  instance = self.new(*args)
  return_value = nil
  instance.with_transaction(transaction) do
    return_value = instance.create
  end
  return return_value
end