Sha256: b74b5b45108e9be7e3b0fb955174b6c44dbbe26c569138c5a76d99a75876f4cb
Contents?: true
Size: 1.43 KB
Versions: 7
Compression:
Stored size: 1.43 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 "dynamo" Kvom::Adapter::DynamodbAdapter.new(connection_spec) when "file" Kvom::Adapter::FilesystemAdapter.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] || "" # up to this point: backend independent # this may be backend dependent (suffix character) 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, end_key + "~") adapter.query(hash_value, range_value) end end def save raise "CmsBaseModel is read-only" end end end
Version data entries
7 entries across 7 versions & 1 rubygems