Skip to content

Refinements not following inheritance #5541

@HoneyryderChuck

Description

@HoneyryderChuck

Environment

Provide at least:

  • JRuby version (jruby -v) : jruby 9.2.5.0 (2.5.0) 2018-12-06 6d5a228 OpenJDK 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [linux-x86_64]
  • Operating system and platform (e.g. uname -a): Linux 4d5914318003 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 Linux

Expected Behavior

I'm refining the URI::Generic class, the base class of all URI's:

module URIExtensions
   refine URI::Generic do
     def authority
        port_string = port == default_port ? nil : ":#{port}"
        "#{host}#{port_string}"
     end
   end
end

where I'll hopefully call this method in URI::HTTP and URI::HTTPS:

URI("http://bang.com:8080").authority #=> "bang.com:8080"

this works on CRuby 2.1 -> 2.5 (probably also 2.6, didn't run it yet)

Actual Behavior

This doesn't work:

URI("http://bang.com:8080").authority #=> NoMethodError: undefined method `authority' for #<URI::HTTP http://bang.com>

# however, this works:

```ruby
URI::Generic.new(scheme: "http", host: "bang.com", port: "8080").authority #=> "bang.com:8080"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions