Sha256: 8aff84d6a7abdb6f088c28a90a948049d998a6505023a4044320502c7a646448
Contents?: true
Size: 705 Bytes
Versions: 19
Compression:
Stored size: 705 Bytes
Contents
module AttrJson module NestedAttributes # Implementation of `build_` methods, called by the `build_` methods # {NestedAttributes} adds. class Builder attr_reader :model, :attr_name, :attr_def def initialize(model, attr_name) @model, @attr_name = model, attr_name, @attr_def = model.class.attr_json_registry[attr_name] end def build(params = {}) if attr_def.array_type? model.send("#{attr_name}=", (model.send(attr_name) || []) + [params]) return model.send("#{attr_name}").last else model.send("#{attr_name}=", params) return model.send("#{attr_name}") end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems