Sha256: 639765b56ac8002e3e87e3a99689a65bf865881b87fc225ab49b8783f50a78a6

Contents?: true

Size: 574 Bytes

Versions: 5

Compression:

Stored size: 574 Bytes

Contents

module Harpy
  class Collection
    include Resource
    attr_reader :items
    def initialize(attrs = nil)
      attrs = attrs || {}
      @items = attrs.delete :items
      super attrs
    end
    def persisted?
      true
    end
    undef :blank?
    alias_method :item, :items
    alias_method :to_a, :items
    alias_method :to_ary, :items
  private
    def method_missing(method, *args, &blk)
      if items.respond_to? method
        result = items.send method, *args, &blk
        result===items ? self : result
      else
        super
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
harpy-0.2.1 lib/harpy/collection.rb
harpy-0.2.0 lib/harpy/collection.rb
harpy-0.1.14 lib/harpy/collection.rb
harpy-0.1.13 lib/harpy/collection.rb
harpy-0.1.12 lib/harpy/collection.rb