Skip to content

Instantly share code, notes, and snippets.

@Ejhfast
Created December 29, 2010 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ejhfast/758641 to your computer and use it in GitHub Desktop.
Save Ejhfast/758641 to your computer and use it in GitHub Desktop.
class FStore
attr_accessor :dynamic_methods
def initialize
@dynamic_methods = []
end
def mix(s1, s2, s3, &block)
name = "#{s1.to_s}_#{s2.to_s}_#{s3.to_s}".to_sym
self.send(name) {|a,b| send(s1, send(s2,a), send(s3,b))}
end
def method_missing(symbol, &block)
if block_given?
self.class.send :define_method, symbol, &block
else
bdy = proc {|*x| symbol}
self.class.send :define_method, symbol, bdy
end
@dynamic_methods << symbol
symbol
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment