Sha256: 3028c7d0f3294a55737f5c6632e11a3e27825aa4f7072ef2116a6098d3b8b59f

Contents?: true

Size: 393 Bytes

Versions: 4

Compression:

Stored size: 393 Bytes

Contents

module HumanAttributes
  module Formatters
    class Custom < Base
      attr_reader :formatter

      def initialize(attribute, type, options)
        @formatter = options.delete(: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

4 entries across 4 versions & 1 rubygems

Version Path
human_attributes-0.3.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.2.0 lib/human_attributes/formatters/custom.rb
human_attributes-0.1.1 lib/human_attributes/formatters/custom.rb
human_attributes-0.1.0 lib/human_attributes/formatters/custom.rb