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
#Usage: | |
# Awesome.configure do |a| | |
# a.magic_number = 3 | |
# end | |
module Awesome | |
class << self | |
attr_accessor :configuration | |
def config | |
self.configuration ||= Configuration.new |
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
##AR 2 | |
Person.find(:all, :conditions => {:name => "Joe", :is_admin => true}, :limit => 10) | |
##=> Array | |
#AR 3 | |
Person.where(:name => 'joe', :is_admin => true).limit(10) | |
##=> ActiveRecord::Relation |
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 Search | |
class << self | |
def where(args) | |
Search.new(args) | |
end | |
end | |
def initialize(args) | |
@search_arguments = args | |
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 Thingy | |
include HTTParty | |
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 HTTParty | |
def self.included(base) | |
base.extend ClassMethods | |
#snip | |
base.instance_variable_set("@default_options", {}) | |
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
backend facebookforcats { | |
.host = "localhost"; | |
.port = "3000"; | |
} |
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 Code | |
def initialize(person) | |
@person = person | |
end | |
def make_bugs | |
"#{@person.name} does some typing" | |
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
module BugMakingSupport | |
def make_bugs | |
"#{@person.name} does some typing" | |
end | |
end | |
class Developer < Employee | |
include BugMakingSupport | |
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 Person | |
attr_accessor :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
class Employee < Person | |
attr_accessor :salary | |
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 LinkedListNode | |
attr_accessor :next, :value | |
def initialize(value) | |
@value = value | |
end | |
end |