Sha256: dada39f45d075e5c5428383734354f2540727003b142aa532b27b54791d4b9dc

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

require 'dm-core'

module DataMapper::Resource
  module PickleAdapter
    include Pickle::Adapter::Base

    # Do not consider these to be part of the class list
    def self.except_classes
      @@except_classes ||= []
    end

    # Gets a list of the available models for this adapter
    def self.model_classes
      ::DataMapper::Model.descendants.to_a.select{|k| !except_classes.include?(k.name)}
    end

    # get a list of column names for a given class
    def self.column_names(klass)
      klass.properties.map(&:name)
    end

    # Get an instance by id of the model
    def self.get_model(klass, id)
      klass.get(id)
    end

    # Find the first instance matching conditions
    def self.find_first_model(klass, conditions)
      klass.first(conditions)
    end

    # Find all models matching conditions
    def self.find_all_models(klass, conditions)
      klass.all(conditions)
    end
    
    # Create a model using attributes
    def self.create_model(klass, attributes)
      klass.create(attributes)
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
pickle-0.5.0 lib/pickle/adapters/data_mapper.rb
pickle-0.4.11 lib/pickle/adapters/data_mapper.rb
pickle-0.4.10 lib/pickle/adapters/data_mapper.rb
pickle-0.4.9 lib/pickle/adapters/data_mapper.rb
pickle-0.4.8 lib/pickle/adapters/data_mapper.rb
pickle-0.4.7 lib/pickle/adapters/data_mapper.rb
pickle-0.4.6 lib/pickle/adapters/data_mapper.rb
pickle-0.4.5 lib/pickle/adapters/data_mapper.rb
pickle-0.4.4 lib/pickle/adapters/data_mapper.rb
judit-pickle-0.4.2 lib/pickle/adapters/data_mapper.rb
pickle-0.4.3 lib/pickle/adapters/data_mapper.rb
pickle-has_many_support-0.4.2 lib/pickle/adapters/data_mapper.rb
pickle-0.4.2 lib/pickle/adapters/data_mapper.rb
pickle-0.4.1 lib/pickle/adapters/data_mapper.rb
pickle-0.4.0 lib/pickle/adapters/data_mapper.rb