Sha256: 8ffff6129745a58eb85115ca6d6faba1a4b86dade8fa56c31a21c901fd7bb992
Contents?: true
Size: 1.44 KB
Versions: 4
Compression:
Stored size: 1.44 KB
Contents
Hello World for ContextR example do class MyApplication def greet "Hello, World" end end app = MyApplication.new assert_equal "Hello, World", app.greet end And what about request coming from down under? Let's introduce Localization. example do class MyApplication in_layer :au do def greet "G'day, mate" end end end app = MyApplication.new assert_equal "Hello, World", app.greet ContextR::with_layer :au do assert_equal "G'day, mate", app.greet end end And what if down under changed its habbits? Let's redefine it. example do class MyApplication in_layer :au do def greet super + " and God Save the Queen" end end end app = MyApplication.new assert_equal "Hello, World", app.greet ContextR::with_layer :au do assert_equal "Hello, World and God Save the Queen", app.greet end end The key here is, that the method `greet` method in the `:au` layer is redefined and no new method is added. example do class MyApplication in_layer :au do $inner_module_1 = self end end class MyApplication in_layer :au do $inner_module_2 = self end end assert(($inner_module_1 == $inner_module_2), "Modules should be equal") end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
contextr-1.0.3 | test/hello_world.mkd |
contextr-1.0.0 | test/hello_world.mkd |
contextr-1.0.1 | test/hello_world.mkd |
contextr-1.0.2 | test/hello_world.mkd |