Class: InactiveRecord::Base
- Inherits:
-
Object
- Object
- InactiveRecord::Base
- Defined in:
- lib/guilded/rails/inactive_record/human_attribute_hint.rb
Class Method Summary collapse
-
.attr_human_hint(attributes) ⇒ Object
:nodoc:.
-
.human_attribute_hint(attribute_key_name) ⇒ Object
Transforms attribute key names into a more humane format, such as “First name” instead of “first_name”.
-
.human_hint_attributes ⇒ Object
Returns a hash of alternate human name conversions set with
attr_human_name
.
Class Method Details
.attr_human_hint(attributes) ⇒ Object
:nodoc:
4 5 6 7 8 9 10 11 12 |
# File 'lib/guilded/rails/inactive_record/human_attribute_hint.rb', line 4 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 |
.human_attribute_hint(attribute_key_name) ⇒ Object
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"
21 22 23 |
# File 'lib/guilded/rails/inactive_record/human_attribute_hint.rb', line 21 def human_attribute_hint(attribute_key_name) #:nodoc: (read_inheritable_attribute("attr_human_hint") || {})[attribute_key_name.to_s] || '' end |
.human_hint_attributes ⇒ Object
Returns a hash of alternate human name conversions set with attr_human_name
.
15 16 17 |
# File 'lib/guilded/rails/inactive_record/human_attribute_hint.rb', line 15 def human_hint_attributes # :nodoc: read_inheritable_attribute("attr_human_hint") end |