Sha256: f91449a51cc50cc9de3570e0f5eb55d6013dc850d50bedeb88c30435ef94d2d5

Contents?: true

Size: 752 Bytes

Versions: 7

Compression:

Stored size: 752 Bytes

Contents

module Mongoid::Acts::NestedSet

  module TestDocument

    def self.included(base)
      base.extend(ClassMethods)
      base.send(:include, InstanceMethods)
    end


    module ClassMethods

      def test_set_dependent_option(val)
        self.acts_as_nested_set_options[:dependent] = val
      end

    end


    module InstanceMethods

      def test_set_attributes(attrs)
        attrs.each do |key, val|
          key = key.to_s
          if Mongoid.allow_dynamic_fields ||
              fields.keys.any? { |k| k.to_s == key } ||
              associations.any? { |a| a[0].to_s == key || a[1].foreign_key.to_s == key }
            @attributes[key] = fields[key].mongoize(val)
          end
        end
        self
      end

    end
  end
end

Version data entries

7 entries across 6 versions & 3 rubygems

Version Path
glebtv-mongoid_nested_set-0.4.1 spec/models/test_document.rb
glebtv-mongoid_nested_set-0.4.0 spec/models/test_document.rb
glebtv-mongoid_nested_set-0.3.0 spec/models/test_document.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid_nested_set-0.2.1/spec/models/test_document.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/bundler/gems/mongoid_nested_set-d482b2642889/spec/models/test_document.rb
mongoid_nested_set-0.2.1 spec/models/test_document.rb
mongoid_nested_set-0.2.0 spec/models/test_document.rb