lib/formotion/section/section.rb in formotion-1.3 vs lib/formotion/section/section.rb in formotion-1.3.1
- old
+ new
@@ -1,5 +1,7 @@
+motion_require "../base"
+
module Formotion
class Section < Formotion::Base
PROPERTIES = [
# Displayed in the section header row
:title,
@@ -36,23 +38,29 @@
rows && rows.each {|row_hash|
row = create_row(row_hash)
}
end
- def build_row(&block)
- row = create_row
- block.call(row)
- row
- end
-
- def create_row(hash = {})
+ def generate_row(hash = {})
row = hash
if hash.class == Hash
row = Formotion::Row.new(hash)
end
row.section = self
row.index = self.rows.count
- # dont move to after the appending.
+ row
+ end
+
+ def build_row(&block)
+ row = generate_row
+ block.call(row)
+ row.after_create
+ self.rows << row
+ row
+ end
+
+ def create_row(hash = {})
+ row = generate_row(hash)
row.after_create
self.rows << row
row
end
\ No newline at end of file