Sha256: 66b2de7290e87ae321112bdd7aa26deac3addff1922f0c730656742c23f83987

Contents?: true

Size: 322 Bytes

Versions: 13

Compression:

Stored size: 322 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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mongomodel-0.2.6 spec/support/models.rb
mongomodel-0.2.5 spec/support/models.rb
mongomodel-0.2.4 spec/support/models.rb
mongomodel-0.2.3 spec/support/models.rb
mongomodel-0.2.2 spec/support/models.rb
mongomodel-0.2.1 spec/support/models.rb
mongomodel-0.2.0 spec/support/models.rb
mongomodel-0.1.6 spec/support/models.rb
mongomodel-0.1.5 spec/support/models.rb
mongomodel-0.1.4 spec/support/models.rb
mongomodel-0.1.3 spec/support/models.rb
mongomodel-0.1.1 spec/support/models.rb
mongomodel-0.1 spec/support/models.rb