Sha256: 4553c01cbaf2d54ae8caad9dab4eff9494ed1674fbd52af7e207feefd4ea9fff

Contents?: true

Size: 678 Bytes

Versions: 4

Compression:

Stored size: 678 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-0.6.0 lib/human_attributes/formatters/base.rb
human_attributes-0.5.0 lib/human_attributes/formatters/base.rb
human_attributes-0.4.0 lib/human_attributes/formatters/base.rb
human_attributes-0.3.1 lib/human_attributes/formatters/base.rb