Sha256: 743f88ac1e95804ec0b5db42fe35dfbf193cdf06c66ef0f79430152663e71081

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

module Disposable::Twin::Property
  module Unnest
    # TODO: test that nested properties options are "unnested", too, e.g. populator.

    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)
      # def_delegators from, name, "#{name}=" # FIXME: this overwrites ActiveSupport#delegate in some cases.

      define_method name do
        send(from).send(name) # TODO: fix Forwardable in Ruby.
      end

      define_method "#{name}=" do |value|
        send(from).send("#{name}=", value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
disposable-0.6.3 lib/disposable/twin/property/unnest.rb
disposable-0.6.2 lib/disposable/twin/property/unnest.rb