Sha256: 91b150fc06ec9e7aa3388426e4d54034256933f5e67d5ae4ac13357492c22950
Contents?: true
Size: 1.59 KB
Versions: 8
Compression:
Stored size: 1.59 KB
Contents
require "kvom" module RailsConnector # This is the abstract class from which all CMS models derive. # class CmsBaseModel < Kvom::Base #:nodoc: class << self def instance_name=(ignore) # :nodoc: # this method is here only for compatibility with the fiona connector. end def adapter @@cms_database_adapter end def configure_database(connection_spec) @@cms_database_adapter = case connection_spec["type"] when "couch" Kvom::Adapter::CouchdbAdapter.new(connection_spec) when "dynamo" Kvom::Adapter::DynamodbAdapter.new(connection_spec) else raise "Unexpected database type #{connection_spec["type"]}" end end def query_index(model, index, params = {}) hash_value = "#{model}/#{index}/#{params[:hash_value]}" range_value = params[:range_value] || "" range_value_extender = params[:range_value_extender] # up to this point: backend independent # this may be backend dependent (suffix character) if range_value_extender start_key, end_key = case range_value when Range [range_value.begin, range_value.end] else [range_value, range_value] end range_value = Range.new(start_key + range_value_extender, end_key + range_value_extender + "~") end adapter.query(hash_value, range_value) end end def save raise "CmsBaseModel is read-only" end end end
Version data entries
8 entries across 8 versions & 1 rubygems