Class: Olelo::Attributes::Attribute Private

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Boolean, Enum, Integer, List, String

Defined Under Namespace

Classes: Boolean, Enum, Integer, List, String, Suggestions

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#keyObject (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

#nameObject (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

#labelObject

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_tagObject

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