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