Class: Merb::Inspector::DMColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/merb_inspector/data.rb

Instance Attribute Summary

Attributes inherited from Column

#context

Instance Method Summary collapse

Methods inherited from Column

#form, #label, #value

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

#nameObject



75
76
77
# File 'lib/merb_inspector/data.rb', line 75

def name
  @property.name.to_s
end

#typeObject



79
80
81
# File 'lib/merb_inspector/data.rb', line 79

def type
  @property.type
end