Sha256: 1c8b90e92d7f3f7c90895cd3618f265878e4282f30243c98b177772245ed6af0
Contents?: true
Size: 1.44 KB
Versions: 5
Compression:
Stored size: 1.44 KB
Contents
require "kvom" module RailsConnector # This is the abstract class from which all CMS models derive. class CmsBaseModel < Kvom::Model::Base class << self def instance_name=(ignore) # 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 = {}, query_options={}) 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, query_options) end end def save raise "CmsBaseModel is read-only" end end end
Version data entries
5 entries across 5 versions & 1 rubygems