Sha256: eec49155adfa54a9bdfb751019f4dabd504f7386e7ed074f61d4c60546285912

Contents?: true

Size: 386 Bytes

Versions: 8

Compression:

Stored size: 386 Bytes

Contents

module HumanAttributes
  module Formatters
    class Custom < Base
      attr_reader :formatter

      def initialize(attribute, type, options)
        @formatter = options[:formatter]
        raise_error('MissingFormatterOption') unless formatter.is_a?(Proc)
        super
      end

      def apply(instance, value)
        formatter.call(instance, value)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
human_attributes-1.1.0 lib/human_attributes/formatters/custom.rb
human_attributes-1.0.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.7.1 lib/human_attributes/formatters/custom.rb
human_attributes-0.7.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.6.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.5.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.4.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.3.1 lib/human_attributes/formatters/custom.rb