class ArticleFixtureGen::Config::Builder

Builds hash with correct keys based on input. What's the value of this, you ask? Two things:

  1. It defines `*_given` entries which are `true` if their corresponding entries are specified, whether those other entries are truthy or not;

  2. It confirms filtering of the input hash, offering a guarantee that any entry accepted is one supported elsehwere in our code.

And yes, this class is awfully procedural. Got ideas for a fix? We'd appreciate your PR!

Attributes

options[R]

Public Class Methods

call(options_hash) click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 21
def self.call(options_hash)
  new.call options_hash
end

Public Instance Methods

call(options) click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 25
def call(options)
  @options = options
  hashes
end

Private Instance Methods

config_hash() click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 34
def config_hash
  value = options[:config]
  given = Internals.string_given?(value)
  { config_given: given }.tap do |ret|
    ret[:config] = value || ''
  end
end
generate_config_hash() click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 42
def generate_config_hash
  value = options[:generate_config]
  given = Internals.string_given?(value)
  { generate_config_given: given }.tap do |ret|
    ret[:generate_config] = value || ''
  end
end
hash_items() click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 57
def hash_items
  items = [:config_hash, :generate_config_hash, :other_hash]
  items.map { |sym| send(sym) }
end
hashes() click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 50
def hashes
  items = hash_items
  {}.tap do |ret|
    items.each { |item| ret.merge! item }
  end
end
other_hash() click to toggle source
# File lib/article_fixture_gen/config/builder.rb, line 62
def other_hash
  ret = Internals.other_specified_values(options)
  ret.merge! Internals.defaults_not_in(ret)
end