Sha256: b1b4ead2ffead51e11a92c2ccd3ea6034659449508fbf0c3c718704e62287996

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

require 'sequel'
require 'consty'
require 'time'
require 'timing'
require 'treetop'
require 'hierarchical_graph'
require 'class_config'
require 'hash_ext'
require 'multi_require'

module Rasti
  module DB
    
    extend MultiRequire
    extend ClassConfig

    require_relative 'db/query'
    require_relative_pattern  'db/relations/*'
    require_relative_pattern  'db/type_converters/postgres_types/*'
    require_relative_pattern  'db/**/*'

    attr_config :type_converters, []

    def self.to_db(db, collection_name, attribute_name, value)
      type_converters.inject(value) do |result, type_converter|
        type_converter.to_db db, collection_name, attribute_name, result
      end
    end

    def self.from_db(value)
      type_converters.inject(value) do |result, type_converter|
        type_converter.from_db result
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rasti-db-2.2.0 lib/rasti/db.rb
rasti-db-2.1.0 lib/rasti/db.rb
rasti-db-2.0.1 lib/rasti/db.rb
rasti-db-2.0.0 lib/rasti/db.rb