Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/milk.rb
Overview
Include metaid for easy metaclass management
Instance Method Summary collapse
-
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class.
-
#haml(path, extras = {}) ⇒ Object
Better integration of haml with our objects.
-
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass.
- #meta_eval(&blk) ⇒ Object
-
#metaclass ⇒ Object
The hidden singleton lurks behind everyone.
Instance Method Details
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class
51 52 53 |
# File 'lib/milk.rb', line 51 def class_def name, &blk class_eval { define_method name, &blk } end |
#haml(path, extras = {}) ⇒ Object
Better integration of haml with our objects
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/milk.rb', line 56 def haml(path, extras={}) filename = "#{Milk::TEMPLATE_DIR}/#{path}.haml" if block_given? ::Haml::Engine.new(File.read(filename), :filename => filename).render(self, extras) do yield end else ::Haml::Engine.new(File.read(filename), :filename => filename).render(self, extras) end end |
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass
46 47 48 |
# File 'lib/milk.rb', line 46 def name, &blk { define_method name, &blk } end |
#meta_eval(&blk) ⇒ Object
43 |
# File 'lib/milk.rb', line 43 def &blk; .instance_eval &blk; end |
#metaclass ⇒ Object
The hidden singleton lurks behind everyone
42 |
# File 'lib/milk.rb', line 42 def ; class << self; self; end; end |