Sha256: 981103e33d68011e8edb3ac7271fd4505c505999632bce0ab3805197420908bc

Contents?: true

Size: 588 Bytes

Versions: 13

Compression:

Stored size: 588 Bytes

Contents

require 'apple-news/additions/base'
Dir["#{File.dirname(__FILE__)}/additions/*.rb"].each { |path| require path }

module AppleNews
  module Addition
    extend self

    def factory(data)
      return if data.nil?
      
      additions.each do |addition|
        if addition.type == data[:type]
          return addition.new(data)
        end
      end

      nil
    end

    private

    def additions
      @additions ||= self.constants.
        map { |const| self.const_get(const) }.
        select { |const| const.name.demodulize != "Base" && const.is_a?(Class) }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
apple-news-0.5.1 lib/apple-news/addition.rb
apple-news-0.5.0 lib/apple-news/addition.rb
apple-news-0.4.2 lib/apple-news/addition.rb
apple-news-0.4.1 lib/apple-news/addition.rb
apple-news-0.4.0 lib/apple-news/addition.rb
apple-news-0.3.1 lib/apple-news/addition.rb
apple-news-0.3.0 lib/apple-news/addition.rb
apple-news-0.2.5 lib/apple-news/addition.rb
apple-news-0.2.4 lib/apple-news/addition.rb
apple-news-0.2.3 lib/apple-news/addition.rb
apple-news-0.2.2 lib/apple-news/addition.rb
apple-news-0.2.1 lib/apple-news/addition.rb
apple-news-0.2.0 lib/apple-news/addition.rb