Class: RDFMapper::Adapters::Rails::Query

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/lib/adapters/rails.rb

Defined Under Namespace

Classes: SQL

Instance Method Summary collapse

Methods included from Logger

#debug, #fatal, #warn

Constructor Details

#initialize(query, options = {}) ⇒ Query

Returns a new instance of Query.



87
88
89
90
91
# File 'lib/lib/adapters/rails.rb', line 87

def initialize(query, options = {})
  @query, @options = query, options
  @rails = (@options[:class_name] || @query.cls.to_s.demodulize).constantize
  setup_replacements
end

Instance Method Details

#createObject

-


104
105
106
107
# File 'lib/lib/adapters/rails.rb', line 104

def create
  record = @rails.create(save_options)
  record_attributes(record)
end

#findObject

-


112
113
114
115
116
117
118
119
120
121
# File 'lib/lib/adapters/rails.rb', line 112

def find
  @query.check(:rails_id)
  #
  #debug 'Searching for %s with %s' % [@rails, @query.inspect]
  #debug 'Query: %s' % find_options.inspect
  #
  @rails.find(:all, find_options).map do |record|
    record_attributes(record)
  end
end

#updateObject

-


96
97
98
99
# File 'lib/lib/adapters/rails.rb', line 96

def update
  record = @rails.update(@query[:rails_id], save_options)
  record_attributes(record)
end