Sha256: 14ed375aa74385546a7edcef2473e598080adbd79d657057e5d2b6c684c79713

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

module Formtastic
  module Inputs
    module Base
      module Naming

        def as
          self.class.name.split("::")[-1].underscore.gsub(/_input$/, '')
        end

        def sanitized_object_name
          object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
        end

        def sanitized_method_name
          @sanitized_method_name ||= method.to_s.gsub(/[\?\/\-]$/, '')
        end

        def attributized_method_name
          method.to_s.gsub(/_id$/, '').to_sym
        end

        def humanized_method_name
          if builder.label_str_method != :humanize
            # Special case where label_str_method should trump the human_attribute_name
            # TODO: is this actually a desired bheavior, or should we ditch label_str_method and
            # rely purely on :human_attribute_name.
            method.to_s.send(builder.label_str_method)
          elsif object && object.class.respond_to?(:human_attribute_name)
            object.class.human_attribute_name(method.to_s)
          else
            method.to_s.send(builder.label_str_method)
          end
        end

        def input_name
          association_primary_key
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/base/naming.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/formtastic-4.0.0/lib/formtastic/inputs/base/naming.rb
formtastic-4.0.0 lib/formtastic/inputs/base/naming.rb
formtastic-4.0.0.rc1 lib/formtastic/inputs/base/naming.rb
formtastic-3.1.5 lib/formtastic/inputs/base/naming.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/formtastic-3.1.4/lib/formtastic/inputs/base/naming.rb
formtastic-3.1.4 lib/formtastic/inputs/base/naming.rb