Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved the Memoizable module to Object. Fixes #1253 #1270

Merged
merged 5 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spec/lucky/memoize_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ require "../spec_helper"

include ContextHelper

# NOTE: The Memoizable module is included in the Object charm
# which gives all Objects access to `memoize`
private class ObjectWithMemoizedMethods
include Lucky::Memoizable
getter times_method_1_called = 0
getter times_method_2_called = 0
getter times_method_3_called = 0
Expand Down
1 change: 1 addition & 0 deletions src/charms/object.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
class Object
include ::Lucky::QuickDef
include ::Lucky::Memoizable
end
1 change: 1 addition & 0 deletions src/lucky.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require "exception_page"
require "habitat"
require "cry"
require "dexter"
require "./lucky/memoizable"
require "./lucky/quick_def"
require "./charms/*"
require "http/server"
Expand Down
1 change: 0 additions & 1 deletion src/lucky/action.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ abstract class Lucky::Action
include Lucky::ActionDelegates
include Lucky::RequestTypeHelpers
include Lucky::Exposable
include Lucky::Memoizable
include Lucky::Routable
include Lucky::Renderable
include Lucky::ParamHelpers
Expand Down
1 change: 0 additions & 1 deletion src/lucky/params.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Lucky::Params
include Avram::Paramable
include Lucky::Memoizable

@request : HTTP::Request
@route_params : Hash(String, String) = {} of String => String
Expand Down
2 changes: 0 additions & 2 deletions src/lucky/request_type_helpers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# Generally the `Accept` header is checked, but some check other headers, such as `X-Requested-With`.
module Lucky::RequestTypeHelpers
include Lucky::Memoizable

private def default_format
{% raise <<-TEXT
Must set 'accepted_formats' or 'default_format' in #{@type} (or its parent class).
Expand Down