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 characters
| -module (test_app). | |
| -compile (export_all). | |
| start() -> | |
| converse_app:start(normal, [?MODULE, receive_function]). | |
| receive_function(From) -> | |
| receive | |
| {data, Socket, Data} -> | |
| case Data of |
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 characters
| require "rubygems" | |
| require "matchy" | |
| require "context" | |
| # Quick 1-file dsl accessor | |
| class Object | |
| def h | |
| @h||={} | |
| end | |
| def method_missing(m,*a,&block) |
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 characters
| define_defaults({ | |
| :access_key => Base.access_key, | |
| :secret_access_key => Base.secret_access_key | |
| }) |
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 characters
| require "rubygems" | |
| require "dslify" | |
| class ATest | |
| def context_stack | |
| $context_stack ||= [] | |
| end | |
| def initialize(&block) | |
| context_stack.push self | |
| instance_eval &block if block |
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 characters
| class Pop | |
| def initialize(&block) | |
| instance_eval &block if block | |
| puts default_doop | |
| end | |
| def default_doop | |
| self.class.doop | |
| end |
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 characters
| class Pop | |
| def initialize(&block) | |
| instance_eval &block if block | |
| end | |
| end | |
| p = Pop.new | |
| p.instance_eval <<-EOE | |
| @b = Pop.new do | |
| puts "self outside: \#\{self\}" |
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 characters
| class A | |
| def meth | |
| puts "In A: #{self}" | |
| end | |
| end | |
| class B < A | |
| def meth | |
| puts "In B: #{self}" | |
| super | |
| end |
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 characters
| module B | |
| def initialize;print "in B -> ";super;end | |
| end | |
| module C | |
| def initialize;puts "in C";end | |
| end | |
| class A | |
| include B, C |
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 characters
| module A | |
| def a_method_from_module_a | |
| puts "I'm a method from within Module A" | |
| end | |
| class B | |
| include A | |
| end | |
| class C | |
| end | |
| end |
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 characters
| require "rubygems" | |
| module Parenting | |
| def context_stack | |
| $context_stack ||= [] | |
| end | |
| def run_in_context &block | |
| context_stack.push self | |
| instance_eval &block if block | |
| context_stack.pop |