Sha256: 4ce0be6af3b014228817adb29795e4c487af912e5d4dddbb39785db6ae6efb9d

Contents?: true

Size: 852 Bytes

Versions: 19

Compression:

Stored size: 852 Bytes

Contents

# encoding: utf-8
require 'mongoid'
module Mongoid #:nodoc:
  module Gator #:nodoc:
    def self.included(base)
      base.class_eval do
        include  Mongoid::Document 
        extend ClassMethods
        class_attribute :gator_keys, :gator_fields
        self.gator_keys = []
        self.gator_fields = []
        delegate :gator_keys, :to => "self.class"
      end
    end
      
    module ClassMethods
      def field(name=nil)
        gator_keys << name
      end
        
      def gator_field(name=nil)
        gator_fields << name
        create_accessors(name)
      end
        
      protected
      def create_accessors(name)
        define_method(name) do
          Gatorer.new(self, name)
        end
        
        define_singleton_method(name) do
            Gatorer.new(self, name)
        end
      end  
    end
    
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gatoroid-0.2.17 lib/gator/gator.rb
gatoroid-0.2.16 lib/gator/gator.rb
gatoroid-0.2.15 lib/gator/gator.rb
gatoroid-0.2.14 lib/gator/gator.rb
gatoroid-0.2.13 lib/gator/gator.rb
gatoroid-0.2.12 lib/gator/gator.rb
gatoroid-0.2.11 lib/gator/gator.rb
gatoroid-0.2.10 lib/gator/gator.rb
gatoroid-0.2.9 lib/gator/gator.rb
gatoroid-0.2.8 lib/gator/gator.rb
gatoroid-0.2.7 lib/gator/gator.rb
gatoroid-0.2.6 lib/gator/gator.rb
gatoroid-0.2.5 lib/gator/gator.rb
gatoroid-0.2.4 lib/gator/gator.rb
gatoroid-0.2.3 lib/gator/gator.rb
gatoroid-0.2.2 lib/gator/gator.rb
gatoroid-0.2.1 lib/gator/gator.rb
gatoroid-0.2.0 lib/gator/gator.rb
gatoroid-0.1.0 lib/gator/gator.rb