Skip to content

Active Resource 6 breaking change: can't share common headers anymore #376

@fabianof

Description

@fabianof

After PR #359 (I guess) has been merged, we can't define common headers on base classes and make them available to subclasses, as expected.

This way, each subclass must configure the same access token, for example, instead of using parent access token, which would not be very DRY.

Please take a look on following sample code (using fruits and apples just like ARes test cases).

# 5.1

fruit = Class.new(ActiveResource::Base)
apple = Class.new(fruit)

fruit.headers["key"] = "fruit-value"

fruit.headers # => {"key"=>"fruit-value"}
apple.headers # => {"key"=>"fruit-value"}

# 6.0

fruit = Class.new(ActiveResource::Base)
apple = Class.new(fruit)

fruit.headers["key"] = "fruit-value"

fruit.headers # => {"key"=>"fruit-value"}
apple.headers # => {}

Please note that if key was access token, for example, then subclasses couldn't get authorized, since apple.headers is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions