Sha256: ebeda5689ed0c5be2412cab4a16b0dfc6f1538e01f731f96b127c96e623fe3c2

Contents?: true

Size: 689 Bytes

Versions: 2

Compression:

Stored size: 689 Bytes

Contents

module Namespaced
  class Comment < BaseClass
    @@id = 0
    @@comments = [nil]

    attr_reader :id
    attr_accessor :author_name, :published_at, :body, :average_rating

    def initialize(attrs = {})
      @id = @@id += 1
      @@comments << self
      attrs.each_pair { |attribute, value| self.send("#{attribute}=", value) }
    end

    def self.get(id)
      @@comments[id]
    end

    def self.get_all(ids)
      ids.map { |id| get(id) }.sort_by { |post| post.id } # this is so that results are not ordered by coincidence
    end
  end

  Sunspot.setup(Comment) do
    text :author_name, :body
    string :author_name
    time :published_at
    integer :average_rating
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
outoftime-sunspot-0.8.8 spec/mocks/comment.rb
outoftime-sunspot-0.8.9 spec/mocks/comment.rb