Sha256: 7d5781f9703f52103c1d5d2d4e4ca5db0fcac104c1f70edef26bc1cc379f5c76
Contents?: true
Size: 736 Bytes
Versions: 4
Compression:
Stored size: 736 Bytes
Contents
# frozen_string_literal: true 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
4 entries across 4 versions & 1 rubygems