Sha256: 08a06d93367d2ef549a4a88e78c36a77d7c30c052121e6a0c6e1576d3943c34c

Contents?: true

Size: 514 Bytes

Versions: 3

Compression:

Stored size: 514 Bytes

Contents

# frozen_string_literal: true

module Danica::VariablesHolder
  class AliasBuilder
    attr_reader :clazz, :origin, :destiny

    def initialize(origin, destiny, clazz)
      @origin = origin
      @destiny = destiny
      @clazz = clazz
    end

    def build
      clazz.variables_hash.change_keys! { |k| k == origin ? destiny : k }
      VariablesBuilder.new([destiny], clazz).build
      clazz.send(:alias_method, "#{origin}=", "#{destiny}=")
      clazz.send(:alias_method, origin, destiny)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.7.7 lib/danica/variables_holder/alias_builder.rb
danica-2.7.6 lib/danica/variables_holder/alias_builder.rb
danica-2.7.5 lib/danica/variables_holder/alias_builder.rb