Parent

Files

Class/Module Index [+]

Quicksearch

Tarantool::LightRecord

Public Class Methods

create(attrs) click to toggle source
# File lib/tarantool/light_record.rb, line 76
def create(attrs)
  new(attrs).save
end
define_field_accessor(name, type) click to toggle source
# File lib/tarantool/light_record.rb, line 64
def define_field_accessor(name, type)
  generated_attribute_methods.class_eval           def #{name}            @attributes[:"#{name}"]          end          def #{name}=(v)            @attributes[:"#{name}"] = v          end, __FILE__, __LINE__ - 1
end
from_fetched(attributes) click to toggle source
# File lib/tarantool/light_record.rb, line 80
def from_fetched(attributes)
  attributes && allocate.__fetched(attributes)
end
generated_attribute_methods() click to toggle source
# File lib/tarantool/light_record.rb, line 57
def generated_attribute_methods
  @generated_attribute_methods ||= begin
      include (mod = Module.new)
      mod
    end
end
new(attributes = nil) click to toggle source
# File lib/tarantool/light_record.rb, line 5
def initialize(attributes = nil)
  @__new_record = true
  @attributes = self.class.default_values.dup
  set_attributes(attributes)  if attributes
  after_init
end

Public Instance Methods

__fetched(attributes) click to toggle source
# File lib/tarantool/light_record.rb, line 12
def __fetched(attributes)
  @__new_record = false
  @attributes = attributes
  after_init
  self
end
after_create() click to toggle source
# File lib/tarantool/light_record.rb, line 50
def after_create; end
after_destroy() click to toggle source
# File lib/tarantool/light_record.rb, line 54
def after_destroy; end
after_init() click to toggle source

callback which runs both after initialization and after fetching from database

# File lib/tarantool/light_record.rb, line 21
def after_init
end
after_save() click to toggle source
# File lib/tarantool/light_record.rb, line 52
def after_save; end
after_update() click to toggle source
# File lib/tarantool/light_record.rb, line 51
def after_update; end
before_create() click to toggle source
# File lib/tarantool/light_record.rb, line 48
def before_create; true end
before_destroy() click to toggle source
# File lib/tarantool/light_record.rb, line 53
def before_destroy; true end
before_save() click to toggle source
# File lib/tarantool/light_record.rb, line 47
def before_save; true end
before_update() click to toggle source
# File lib/tarantool/light_record.rb, line 49
def before_update; true end
destroy() click to toggle source
# File lib/tarantool/light_record.rb, line 40
def destroy
  return false  unless before_destroy
  self.class.delete id
  after_destroy
  true
end
save() click to toggle source
# File lib/tarantool/light_record.rb, line 24
def save
  return false  unless before_save
  if @__new_record
    return false  unless before_create
    self.class.insert(@attributes)
    @__new_record = false
    after_create
  else
    return false  unless before_update
    self.class.replace(@attributes)
    after_update
  end
  after_save
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.