Sha256: 02a9dc6465951626a5bfd21d3541c7f8a42e63befc9f65fc664e2e2e14f879b3

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

require 'thanos/api/client'
require 'thanos/response_holder'
require 'thanos/factories/story'

module Thanos
  class StoryFinder
    ATTRIBUTES = [:modifiedSince, :comics, :series, :events, :creators,
                  :characters]

    ATTRIBUTES.each do |attribute|
      parameter = StringActions.parameterize(attribute.to_s)
      define_method("find_by_#{parameter}") do |attr|
        find("#{attribute}".to_sym => attr)
      end
    end

    def find(attribute)
      FinderValidator.validate(attribute, ATTRIBUTES)
      response = Thanos::API::Client.new.get(:stories, attribute)
      results = Thanos::ResponseHolder.new(response).results
      Thanos::Factory::Story.new(results).build
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thanos-0.6.0 lib/thanos/finders/story_finder.rb
thanos-0.5.0 lib/thanos/finders/story_finder.rb