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.



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

def initialize(context, property)
  @context  = context
  @property = property
end

Instance Method Details

#default_form(record) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/merb_inspector/data.rb', line 96

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



87
88
89
90
91
92
93
94
# File 'lib/merb_inspector/data.rb', line 87

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



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

def name
  @property.name.to_s
end

#typeObject



83
84
85
# File 'lib/merb_inspector/data.rb', line 83

def type
  @property.type
end