class Marionette::Attribute
Attributes
column_name[RW]
field_type[RW]
type[RW]
Public Class Methods
new(name, type=nil)
click to toggle source
# File lib/generators/marionette/attribute.rb, line 8 def initialize(name, type=nil) @column_name = name @type = type || :string end
Public Instance Methods
html()
click to toggle source
# File lib/generators/marionette/attribute.rb, line 31 def html capture do wrapper = self.wrapper do concat((' '*4 + label_html).html_safe) concat "\n" concat((' '*4 + input_html).html_safe) end end end
input_html()
click to toggle source
# File lib/generators/marionette/attribute.rb, line 21 def input_html eval("#{self.field_type}_tag(:#{self.column_name})") end
label_html()
click to toggle source
# File lib/generators/marionette/attribute.rb, line 17 def label_html label_tag(column_name.to_sym) end
password_digest?()
click to toggle source
# File lib/generators/marionette/attribute.rb, line 13 def password_digest? @column_name == 'password' && @type == 'digest' end
wrapper(&block)
click to toggle source
# File lib/generators/marionette/attribute.rb, line 25 def wrapper(&block) output = "<div class=\"field\">\n".html_safe output << capture(&block) output.safe_concat("\n </div>") end