Class: Olelo::Attributes::Attribute Private
- Includes:
- Util
- Defined in:
- lib/olelo/attributes.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Attribute data structure
Defined Under Namespace
Classes: Boolean, Enum, Integer, List, String, Suggestions
Instance Attribute Summary collapse
- #key ⇒ Object readonly private
- #name ⇒ Object readonly private
Instance Method Summary collapse
- #build_form(attr) ⇒ Object private
-
#initialize(parent, name) ⇒ Attribute
constructor
private
A new instance of Attribute.
- #label ⇒ Object private
- #label_tag ⇒ Object private
Methods included from Util
#check, #decode64, #deep_copy, #encode64, #escape, #escape_html, #escape_javascript, included, #md5, #no_cache?, #sha256, #titlecase, #truncate, #unescape, #unescape_backslash, #unescape_html, #valid_xml_chars?, #yaml_dump, #yaml_load, #yaml_load_file
Constructor Details
#initialize(parent, name) ⇒ Attribute
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Attribute.
16 17 18 19 |
# File 'lib/olelo/attributes.rb', line 16 def initialize(parent, name) @name = name.to_s @key = ['attribute', parent.path, name].compact.join('_') end |
Instance Attribute Details
#key ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/olelo/attributes.rb', line 14 def key @key end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/olelo/attributes.rb', line 14 def name @name end |
Instance Method Details
#build_form(attr) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/olelo/attributes.rb', line 31 def build_form(attr) "#{label_tag}#{field_tag(attr)}<br/>" end |
#label ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/olelo/attributes.rb', line 21 def label @label ||= Locale.translate(key, fallback: titlecase(name)) end |
#label_tag ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 |
# File 'lib/olelo/attributes.rb', line 25 def label_tag type = self.class.name.split('::').last.downcase title = Locale.translate("type_#{type}", fallback: titlecase(type)) %{<label for="#{key}" title="#{escape_html title}">#{escape_html label}</label>} end |