Sha256: 324f30cf15150a849a6012498e548fe82494cac54dd9c3db87f5b18000d1a1fe

Contents?: true

Size: 448 Bytes

Versions: 1

Compression:

Stored size: 448 Bytes

Contents

class BuildModel
  def self.[] form, model
    new(PR::FieldRegistry).for form, model
  end

  def initialize registry
    @registry = registry
  end

  def for form, model
    @registry.fields_for(form) do |field_name|
      set model, field_name, value(form,field_name)
    end
  end

  private
    def set thing, name, value
      thing.send "#{name}=", value
    end
    def value thing, name
      thing.send("__#{name}").convert
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pr-0.0.1 lib/pr/build_model.rb