lib/spontaneous/collections/field_set.rb in spontaneous-0.2.0.beta5 vs lib/spontaneous/collections/field_set.rb in spontaneous-0.2.0.beta6

- old
+ new

@@ -3,12 +3,12 @@ module Spontaneous::Collections class FieldSet < PrototypeSet attr_reader :owner - def initialize(owner, initial_values) - super() + def initialize(owner, initial_values, superobject = nil, superset_name = nil) + super(superobject, superset_name) @owner = owner @field_data = initial_values initialize_from_prototypes end @@ -25,10 +25,18 @@ def saved self.each { |field| field.mark_unmodified } end + def with_dynamic_default_values + select { |field| field.prototype.dynamic_default? } + end + + def prototypes + map(&:prototype) + end + # Lazily load fields by name def named(name) super || load_field(owner.field_prototypes[name.to_sym]) end @@ -38,12 +46,16 @@ # def render(format = :html, locals = {}, parent_context = nil) map { |field| wrap_field_value(field, field.render(format, locals), format) }.join("\n") end + alias_method :render_inline, :render + def render_using(renderer, format = :html, locals = {}, parent_context = nil) map { |field| wrap_field_value(field, field.render_using(renderer, format, locals), format) }.join("\n") end + + alias_method :render_inline_using, :render_using protected def wrap_field_value(field, value, format) case format