Last active
March 11, 2022 17:51
-
-
Save havenwood/a81401724cbcbf1f78e79f42ed4b0e33 to your computer and use it in GitHub Desktop.
Revisions
-
havenwood revised this gist
Mar 11, 2022 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,9 @@ def foo an_instance.foo #=> "tabmow" an_instance.foo #=> "wombat" another_instance = MultipleInstancesOfState.new(state: 'corge') another_instance.foo #=> "egroc" -
havenwood revised this gist
Feb 24, 2022 . 3 changed files with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,6 @@ def foo an_instance.foo #=> "tabmow" another_instance = MultipleInstancesOfState.new(state: 'tabmow') another_instance.foo #=> "wombat" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ module NoState module_function def foo(stateless:) stateless.reverse end end NoState.foo(stateless: 'wombat') #=> "tabmow" NoState.foo(stateless: 'tabmow') #=> "wombat" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,5 +18,5 @@ def foo singleton_instance.state = 'wombat' singleton_instance.foo #=> "tabmow" singleton_instance.foo #=> "wombat" -
havenwood revised this gist
Feb 21, 2020 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,3 +7,7 @@ def foo(bar:) end NoState.foo(bar: 'wombat') #=> "tabmow" NoState.foo(bar: 'tabmow') #=> "wombat" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,5 +18,5 @@ def foo singleton_instance.state = 'wombat' singleton_instance.foo #=> "tabmow" SingleInstanceOfState.instance.foo #=> "wombat" -
havenwood created this gist
Feb 20, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ class MultipleInstancesOfState attr_accessor :state def initialize(state:) @state = state end def foo @state.reverse! end end an_instance = MultipleInstancesOfState.new(state: 'wombat') an_instance.foo #=> "tabmow" another_instance = MultipleInstancesOfState.new(state: 'wombat') another_instance.foo #=> "tabmow" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ module NoState module_function def foo(bar:) bar.reverse end end NoState.foo(bar: 'wombat') This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ require 'singleton' class SingleInstanceOfState include Singleton attr_accessor :state def initialize @state = nil end def foo @state.reverse! end end singleton_instance = SingleInstanceOfState.instance singleton_instance.state = 'wombat' singleton_instance.foo #=> "tabmow" singleton_instance.foo #=> "wombat"