This file contains 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 'mixology' | |
module Callback | |
def before_filter filter, filtered_method | |
Callback.method_factory(filter, filtered_method) | |
end | |
# Needed defin_method here so it's called in module's context | |
def self.method_factory(filter, filtered_method) |
This file contains 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 'mixology' | |
module Callback | |
def cost | |
spoon_required | |
super | |
end | |
end |
This file contains 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 'mixology' | |
module Callback | |
def before_filter filter, filtered_method | |
Callback.method_factory(filter, filtered_method) | |
end | |
# Needed defin_method here so it's called in module's context | |
def self.method_factory(filter, filtered_method) |
This file contains 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 'mixology' | |
module Callback | |
def filter_with filter, filtered_method | |
Callback.method_factory(filter, filtered_method) | |
end | |
def before_filter filter | |
methods = self.class.instance_methods(false) |
This file contains 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 'facets' | |
module Creme | |
def cost | |
puts "before_filter" | |
super | |
end | |
end |
This file contains 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 "uninclude" | |
module Core | |
def save; "saved" end | |
end | |
module Dirty | |
def save; "clean + " + super end | |
end |
This file contains 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 MyTransaction | |
def save | |
Transaction.instance_eval do | |
@@save = instance_method(:save) | |
remove_method :save | |
end | |
body = "my transaction! + " + super | |
Transaction.module_eval do |
This file contains 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 Asset < ActiveRecord::Base | |
acts_as_taggable_on :tags, :people | |
# FIRST ATTEMPT | |
def tag_list=(new_tags) | |
set_tag_list_on('tags',new_tags.downcase) | |
end | |
def person_list=(new_tags) | |
set_tag_list_on('people',new_tags.downcase) |
This file contains 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 "xml/libxml" | |
#require "active_support" | |
def traverse(node) | |
children = node.children.select {|a| a.element?} | |
txt = "<h1>HTML output</h1><ul>" | |
last_depth, depth = 1, 1 |
This file contains 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 Mongoid | |
def self.included(base) | |
base.extend NoProxyAssociation | |
end | |
# This little piece of codes creates an author method in Book | |
# which instanciates an anonymous class with Author included! | |
# def author | |
# klass = Class.new do | |
# include Book::Author |