Sha256: 4c10f1617827fffa63d20ba67645c199f29d325849cf828c23389fce2c8c4da5

Contents?: true

Size: 704 Bytes

Versions: 9

Compression:

Stored size: 704 Bytes

Contents

module NotRelational


class Reference
    attr_accessor :target_class 
    attr_accessor :primary_key 
    attr_accessor :index 
  def initialize(options={})
      if options.has_key?(:target)
          self.target_class=options[:target].class.name.to_sym
          self.primary_key=options[:target].primary_key
      end
      self.index=-1
      if options.has_key?(:index)
          self.index=options[:index]
      end
  end
  def targets?(item)
      return false unless item 
      self.target_class==item.class.name.to_sym and self.primary_key==item.primary_key
  end
  def get_target
      the_class=Kernel.const_get(self.target_class)
      the_class.find(self.primary_key)
      
  end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cloudwow-not_relational-0.1.0 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.11 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.2 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.3 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.5 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.6 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.7 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.8 lib/not_relational/reference.rb
cloudwow-not_relational-0.1.9 lib/not_relational/reference.rb