Class: Merb::Inspector::DMColumn
- Defined in:
- lib/merb_inspector/data.rb
Instance Attribute Summary
Attributes inherited from Column
Instance Method Summary collapse
- #default_form(record) ⇒ Object
- #default_value(record) ⇒ Object
-
#initialize(context, property) ⇒ DMColumn
constructor
A new instance of DMColumn.
- #name ⇒ Object
- #type ⇒ Object
Methods inherited from Column
Constructor Details
#initialize(context, property) ⇒ DMColumn
Returns a new instance of DMColumn.
70 71 72 73 |
# File 'lib/merb_inspector/data.rb', line 70 def initialize(context, property) @context = context @property = property end |
Instance Method Details
#default_form(record) ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/merb_inspector/data.rb', line 92 def default_form(record) if type == ::DataMapper::Types::Serial record.send name elsif type == ::DataMapper::Types::Text raise MethodFound.new(:text_area, name.to_sym) else raise MethodFound.new(:text_field, name.to_sym) end end |
#default_value(record) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/merb_inspector/data.rb', line 83 def default_value(record) value = record.send(name) if type == ::DataMapper::Types::Text value.to_s.split(/\r?\n/).map{|i| h(i.to_s)}.join("<BR>") else h(value.to_s) end end |
#name ⇒ Object
75 76 77 |
# File 'lib/merb_inspector/data.rb', line 75 def name @property.name.to_s end |
#type ⇒ Object
79 80 81 |
# File 'lib/merb_inspector/data.rb', line 79 def type @property.type end |