Sha256: 7452767761829b2b104d22628e0112dee8215c78f12c5b674ce327e7d1f5c2be

Contents?: true

Size: 513 Bytes

Versions: 4

Compression:

Stored size: 513 Bytes

Contents

module Socialcastr
  class Collection < Base
    include Enumerable

    def each &block
      members.each{|member| block.call(member)}
    end

    def size
      members.size
    end

    def members
      send self.class.members_method
    end

    def self.collection_of(name, options={})
      if options[:as]
        @members_method = options[:as]
      else
        @members_method = name
      end
      elements name, options
    end

    def self.members_method
      @members_method
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
socialcastr-0.1.3 lib/socialcastr/collection.rb
socialcastr-0.1.2 lib/socialcastr/collection.rb
socialcastr-0.1.1 lib/socialcastr/collection.rb
socialcastr-0.1.0 lib/socialcastr/collection.rb