class Olelo::Attributes::Attribute

Attribute data structure @api private

Attributes

key[R]

@api private

name[R]

@api private

Public Class Methods

new(parent, name) click to toggle source
# File lib/olelo/attributes.rb, line 16
def initialize(parent, name)
  @name = name.to_s
  @key = ['attribute', parent.path, name].compact.join('_')
end

Public Instance Methods

build_form(attr) click to toggle source
# File lib/olelo/attributes.rb, line 31
def build_form(attr)
  "#{label_tag}#{field_tag(attr)}<br/>"
end
label() click to toggle source
# File lib/olelo/attributes.rb, line 21
def label
  @label ||= Locale.translate(key, fallback: titlecase(name))
end
label_tag() click to toggle source
# 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