Sha256: 88f9c802482a9ac674f8120ea37365e652f7c865b3dbc646a8b6fb7222a5a6a6

Contents?: true

Size: 599 Bytes

Versions: 43

Compression:

Stored size: 599 Bytes

Contents

# frozen_string_literal: true

require "refinements/strings"

module Pennyworth
  module Loaders
    # Loads an array of text records.
    class Text
      using Refinements::Strings

      TRANSFORMS = %w[camelcase capitalize downcase size snakecase titleize upcase].freeze

      def initialize transforms: TRANSFORMS, model: Models::Text
        @transforms = transforms
        @model = model
      end

      def call content
        transforms.map { |kind| model[id: kind, content: content.public_send(kind)] }
      end

      private

      attr_reader :transforms, :model
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
pennyworth-13.5.0 lib/pennyworth/loaders/text.rb
pennyworth-13.4.0 lib/pennyworth/loaders/text.rb
pennyworth-13.3.0 lib/pennyworth/loaders/text.rb
pennyworth-13.2.0 lib/pennyworth/loaders/text.rb
pennyworth-13.1.0 lib/pennyworth/loaders/text.rb
pennyworth-13.0.1 lib/pennyworth/loaders/text.rb
pennyworth-13.0.0 lib/pennyworth/loaders/text.rb
pennyworth-12.3.1 lib/pennyworth/loaders/text.rb
pennyworth-12.3.0 lib/pennyworth/loaders/text.rb
pennyworth-12.2.0 lib/pennyworth/loaders/text.rb
pennyworth-12.1.0 lib/pennyworth/loaders/text.rb
pennyworth-12.0.2 lib/pennyworth/loaders/text.rb
pennyworth-12.0.1 lib/pennyworth/loaders/text.rb
pennyworth-12.0.0 lib/pennyworth/loaders/text.rb
pennyworth-11.2.2 lib/pennyworth/loaders/text.rb
pennyworth-11.2.1 lib/pennyworth/loaders/text.rb
pennyworth-11.2.0 lib/pennyworth/loaders/text.rb
pennyworth-11.1.3 lib/pennyworth/loaders/text.rb
pennyworth-11.1.2 lib/pennyworth/loaders/text.rb
pennyworth-11.1.1 lib/pennyworth/loaders/text.rb