Sha256: 549aca15f0d5843a2bb0481b5245653b75b70274343506d4035ad244e61832b2

Contents?: true

Size: 1 KB

Versions: 17

Compression:

Stored size: 1 KB

Contents

module InactiveRecord
  class Base
    class <<self
      def attr_human_hint(attributes) # :nodoc:
        #return unless table_exists?

        attributes.stringify_keys!
        write_inheritable_hash("attr_human_hint", attributes || {})

        # assign the current class to each column that is being assigned a new human attribute name
        self.columns.reject{|c| !attributes.has_key?(c.name)}.each{|c| c.parent_record_class = self}
      end

      # Returns a hash of alternate human name conversions set with <tt>attr_human_name</tt>.
      def human_hint_attributes # :nodoc:
        read_inheritable_attribute("attr_human_hint")
      end

      # Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example:
      #   Person.human_attribute_name("first_name") # => "First name"
      def human_attribute_hint(attribute_key_name) #:nodoc:
        (read_inheritable_attribute("attr_human_hint") || {})[attribute_key_name.to_s] || ''
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
midas-guilded-0.2.9 lib/guilded/rails/inactive_record/human_attribute_hint.rb
midas-guilded-0.3.0 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.1.0 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.14 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.13 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.12 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.10 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.9 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.8 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.7 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.6 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.5 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.4 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.3 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.2 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.1 lib/guilded/rails/inactive_record/human_attribute_hint.rb
guilded-1.0.0 lib/guilded/rails/inactive_record/human_attribute_hint.rb