Project

General

Profile

Actions

Bug #12251

closed

DelegateClass(OpenStruct) behavior in 2.3.0 different from 2.2

Added by dblock (Daniel Doubrovkine) over 8 years ago. Updated about 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
[ruby-core:74822]
Tags:

Description

This came from https://github.com/ruby-grape/grape/issues/1348

require 'delegate'
require 'ostruct'

class AttributeTranslator < DelegateClass(OpenStruct)
  def initialize(attributes = {})
    ostruct = OpenStruct.new(attributes)
    super ostruct
  end
end

def namespace
  'foobar'
end

instance = AttributeTranslator.new(namespace: '/')
puts instance.namespace

Ruby 2.2.1

=> '/'

Ruby 2.3.0

=> 'foobar'

Halp?


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #12136: OpenStruct.new(format: :bar).send :format # => too few argumentsClosedActions
Actions #1

Updated by marcandre (Marc-Andre Lafortune) over 8 years ago

  • Related to Bug #12136: OpenStruct.new(format: :bar).send :format # => too few arguments added

Updated by matz (Yukihiro Matsumoto) over 4 years ago

Hmm, it was caused by OpenStruct performance pull-request. Maybe we should revert the PR?

Matz.

Updated by jeremyevans0 (Jeremy Evans) about 4 years ago

  • Status changed from Open to Closed

The OpenStruct changes were reverted starting around e026e186f4a01aa3f6cd02ae6ef33f44f129361c, so you once again get / output for the program.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0