Sha256: cbea6a163a26f25aff9e890ffe26baf7a19bee84a0fa32e8f593de49f3cd1d51

Contents?: true

Size: 646 Bytes

Versions: 10

Compression:

Stored size: 646 Bytes

Contents

require "uber/delegates"

module Disposable::Twin::Property
  module Unnest
    # TODO: test that nested properties options are "unnested", too, e.g. populator.
    def self.included(includer)
      includer.send(:include, Uber::Delegates)
    end

    def unnest(name, options)
      from = options.delete(:from)
      # needed to make reform process this field.

      options = definitions.get(from)[:nested].definitions.get(name).instance_variable_get(:@options) # FIXME.
      options = options.merge(virtual: true, _inherited: true, private_name: nil)

      property(name, options)
      delegates from, name, "#{name}="
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
disposable-0.5.0 lib/disposable/twin/property/unnest.rb
disposable-0.4.7 lib/disposable/twin/property/unnest.rb
disposable-0.4.6 lib/disposable/twin/property/unnest.rb
disposable-0.4.5 lib/disposable/twin/property/unnest.rb
disposable-0.4.4 lib/disposable/twin/property/unnest.rb
disposable-0.4.3 lib/disposable/twin/property/unnest.rb
disposable-0.4.2 lib/disposable/twin/property/unnest.rb
disposable-0.4.1 lib/disposable/twin/property/unnest.rb
disposable-0.4.0 lib/disposable/twin/property/unnest.rb
disposable-0.3.2 lib/disposable/twin/property/unnest.rb