Sha256: 7d514cd57c528dc8b76650c07d72c726d16fe497ea41b0f661b3a56914e2773b

Contents?: true

Size: 679 Bytes

Versions: 4

Compression:

Stored size: 679 Bytes

Contents

module HumanAttributes
  module Formatters
    class Base
      include HumanAttributes::Config

      attr_reader :attribute, :type, :options, :default, :suffix

      def initialize(attribute, type, options)
        @attribute = attribute.to_sym
        @type = type.to_sym
        @default = options[:default]
        @suffix = options[:suffix]
        @options = options
      end

      def method_name
        return "human_#{attribute}" if suffix.blank?
        return "#{attribute}_#{suffix_by_type(type)}" if suffix == true

        "#{attribute}_#{suffix}"
      end

      def apply(_instance, _value)
        raise_error('NotImplemented')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
human_attributes-1.1.0 lib/human_attributes/formatters/base.rb
human_attributes-1.0.0 lib/human_attributes/formatters/base.rb
human_attributes-0.7.1 lib/human_attributes/formatters/base.rb
human_attributes-0.7.0 lib/human_attributes/formatters/base.rb