Sha256: 78f590c0441ad9961a4b27f8f82e49a20957ce8620425e2454ead85f0954b028

Contents?: true

Size: 651 Bytes

Versions: 37

Compression:

Stored size: 651 Bytes

Contents

class CustomClass
  attr_reader :name
  
  def initialize(name)
    @name = name
  end
  
  def ==(other)
    other.is_a?(self.class) && name == other.name
  end
  
  def to_mongo
    { :name => name }
  end
  
  def self.from_mongo(hash)
    new(hash[:name])
  end
  
  def self.cast(value)
    new(value.to_s)
  end
end

class CustomClassWithDefault < CustomClass
  def self.mongomodel_default(doc)
    new("Custom class default")
  end
end

class CustomClassWithAccessors < CustomClass
  def self.mongomodel_accessors(property)
    Module.new do
      define_method(:custom_accessor) do
        "Custom accessor method"
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
mongomodel-0.5.5 spec/support/models.rb
mongomodel-0.5.4 spec/support/models.rb
mongomodel-0.5.3 spec/support/models.rb
mongomodel-0.5.2 spec/support/models.rb
mongomodel-0.5.1 spec/support/models.rb
mongomodel-0.5.0 spec/support/models.rb
mongomodel-0.4.9 spec/support/models.rb
mongomodel-0.4.8 spec/support/models.rb
mongomodel-0.4.7 spec/support/models.rb
mongomodel-0.4.6 spec/support/models.rb
mongomodel-0.4.5 spec/support/models.rb
mongomodel-0.4.4 spec/support/models.rb
mongomodel-0.4.3 spec/support/models.rb
mongomodel-0.4.2 spec/support/models.rb
mongomodel-0.4.1 spec/support/models.rb
mongomodel-0.4.0 spec/support/models.rb
mongomodel-0.3.6 spec/support/models.rb
mongomodel-0.3.5 spec/support/models.rb
mongomodel-0.3.4 spec/support/models.rb
mongomodel-0.3.3 spec/support/models.rb