Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1077

Block Field-Building DSL

      Create a DSL for building fields using blocks and instance_exec'd methods rather than passing options hashes. Include attr_accessible and validates in this DSL since these methods when sent to the class still have to operate on individual fields. Messages sent in the block would override corresponding hash keys.

      class Pet
      include Mongoid::Document

      field :ferocious do
      type Boolean
      default false
      end

      field :name do
      type String
      default

      { ferocious? ? "Jaws" : "Sparky" }

      attr_accessible
      validates :presence => true
      end

      belongs_to :owner do
      class_name "Person"
      attr_accessible
      end
      end

            Assignee:
            Unassigned Unassigned
            Reporter:
            yfeldblum yfeldblum
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: