Sha256: e2eca276a124a5ccd7d2ed407450f24ca676dd194829ce5c1ea8e0f4a64ca846
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'ripple' # Monkey likes to patch module Ripple::Document::ClassMethods def reference_one(name, opts={}) name = name.to_s kls = opts[:class] || name.camelize.constantize property :"#{name}_key", String class_eval <<-CODE def #{name} @#{name} ||= #{kls}.find(#{name}_key) end def #{name}=(doc) if doc.class != #{kls} raise "got " + doc.class + ", expected #{kls}" end raise "must have a key" unless doc.key @#{name} = doc self.#{name}_key = doc.key end CODE end def reference_many(name, opts={}) kls = opts[:class] raise 'not imlemented yet' end def one_mutual(name, opts={}) as = opts[:as] kls = opts[:class] raise 'not imlemented yet' end def many_mutual(name, opts={}) as = opts[:as] kls = opts[:class] raise 'not imlemented yet' end def reference_one_mutual(name, opts={}) as = opts[:as] kls = opts[:class] raise 'not imlemented yet' end def reference_many_mutual(name, opts={}) as = opts[:as] kls = opts[:class] raise 'not imlemented yet' end ### TOKENS def token(name, &blk) property name, String, :default => blk || lambda { ActiveSupport::SecureRandom.urlsafe_base64(16) } end def token_key!(&blk) token(:token, &blk) key_on :token end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ripple_oh_caramba-0.1.0 | lib/ripple_oh_caramba.rb |