Sha256: f78126e02056b8b14710888cd2b5e7cd6323a93a92c01db002482bfa8e3f3773

Contents?: true

Size: 692 Bytes

Versions: 4

Compression:

Stored size: 692 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.delete(:default)
        @suffix = options.delete(: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.3.0 lib/human_attributes/formatters/base.rb
human_attributes-0.2.0 lib/human_attributes/formatters/base.rb
human_attributes-0.1.1 lib/human_attributes/formatters/base.rb
human_attributes-0.1.0 lib/human_attributes/formatters/base.rb