Sha256: 3d2a130548efff56de68c13b25a93ccf4792bd306c810c235992b58753b3fb52

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

require 'pickle'

module FWToolkit
  module Test
    class FrankModel

      attr_accessor :id, :core_data_entity

      module PickleAdapter
        include Pickle::Adapter::Base

        # Gets a list of the available models for this adapter
        def self.model_classes
          klasses = ::FWToolkit::Test::FrankModel.__send__(:descendants)

          #klasses.select do |klass|
          #  !klass.abstract_class? && klass.table_exists? && !except_classes.include?(klass.name)
          #end
        end

        # get a list of column names for a given class
        def self.column_names(klass)
          #klass.column_names
          []
        end

        # Get an instance by id of the model
        def self.get_model(klass, id)
          FWToolkit::Test::FrankModel.object_in_cache(id)
        end

        # Find the first instance matching conditions
        def self.find_first_model(klass, conditions)
          #klass.find(:first, :conditions => conditions)
          puts "find_first_model"
        end

        # Find all models matching conditions
        def self.find_all_models(klass, conditions)
          #klass.find(:all, :conditions => conditions)
          puts "find_all_models"
        end

        # Create a model using attributes
        def self.create_model(klass, attributes)
          puts "create_model"
        end
      end

      @@object_cache = {}

      def self.object_in_cache(id)
        return @@object_cache[id.to_s]
      end

      def save!
        self.id = self.object_id
        @@object_cache[self.object_id.to_s] = self
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fwtoolkit-0.3.4 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.3.3 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.3.2 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.3.1 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.3.0 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.2.1 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.2.0 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.1.2 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.1.1 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.1.0 lib/fwtoolkit/test/frank_model.rb
fwtoolkit-0.0.6 lib/fwtoolkit/test/frank_model.rb