Skip to content

Commit

Permalink
Correct the eval context when defining class state
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanp committed Aug 7, 2019
1 parent 2ae5e54 commit 62112dc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions pakyow-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [fixed] Unpredictable load order of backend aspects
* Now loaded alphabetically on every os
* [fixed] App connection path is relative to to the app mount path
* [fixed] Methods defined an an app block are now correctly defined

# 1.0.1

Expand Down
19 changes: 19 additions & 0 deletions pakyow-core/spec/features/app/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,23 @@ def load_pipeline_defaults(pipeline)
expect(app.config.name).to eq("define-test")
end
end

context "app block defines a method" do
let :app_def do
Proc.new do; end
end

let :app_init do
Proc.new do
def call(connection)
connection.body = StringIO.new("called")
connection.halt
end
end
end

it "defines the method" do
expect(call("/")[2]).to eq("called")
end
end
end
2 changes: 1 addition & 1 deletion pakyow-support/lib/pakyow/support/definable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def stateful(name, object, &stateful_block)
# Define state for the object.
#
def define(&block)
instance_eval(&block)
class_eval(&block)
end
end

Expand Down

0 comments on commit 62112dc

Please sign in to comment.