Module: Kalimba::Persistence::Redlander

Extended by:
ActiveSupport::Concern
Includes:
Kalimba::Persistence
Defined in:
lib/kalimba/persistence/redlander.rb

Overview

Redlander-based persistence module

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Kalimba::Persistence

REPOSITORY_OPTIONS_MAPPING

Instance Method Summary collapse

Methods included from Kalimba::Persistence

backend, repository

Instance Method Details

#destroyObject



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/kalimba/persistence/redlander.rb', line 136

def destroy
  if !destroyed? && persisted?
    Kalimba.repository.transaction do
      logger.debug("destroying #{self.inspect}") if logger
      Kalimba.repository.statements.delete_all(:subject => subject)
    end
    super
  else
    false
  end
end

#new_record?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/kalimba/persistence/redlander.rb', line 122

def new_record?
  !(destroyed? || persisted?)
end

#persisted?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/kalimba/persistence/redlander.rb', line 126

def persisted?
  !subject.nil? && Kalimba.repository.statements.exist?(:subject => subject)
end

#reloadObject



130
131
132
133
134
# File 'lib/kalimba/persistence/redlander.rb', line 130

def reload
  logger.debug("reloading #{self.inspect}") if logger
  self.class.properties.each { |name, _| attributes[name] = retrieve_attribute(name) }
  self
end

#save(options = {}) ⇒ Object



148
149
150
151
152
153
154
# File 'lib/kalimba/persistence/redlander.rb', line 148

def save(options = {})
  @subject ||= generate_subject
  logger.debug("saving #{self.inspect}") if logger
  Kalimba.repository.transaction do
    store_type && store_attributes(options) && super
  end
end