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 Orders::Step1Controller < PublicController | |
| def new | |
| end | |
| def create | |
| end | |
| protected |
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 PostsController | |
| # You could believe we have a FcousedAction module that gives us | |
| # good defaults. It exposes things like +action+ for defining | |
| # normal RESTful actions. | |
| include FocusedActions | |
| # Example 1: | |
| # The default behaviour is enough. | |
| action :index | |
| action :create |
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
| @implementation Test1 | |
| - (id)init { | |
| self = [super init]; | |
| if (self) { | |
| [self addObserver:self forKeyPath:@"property1" options:0 context:NULL]; | |
| [self addObserver:self forKeyPath:@"property2" options:0 context:NULL]; | |
| } | |
| } |
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 'test_helper' | |
| class PayPalExpress::TransactionSearchTest < ActiveSupport::TestCase | |
| test "#search returns a collection of transactions" do | |
| account = MiniTest::Mock.new | |
| period = MiniTest::Mock.new | |
| requester = MiniTest::Mock.new | |
| params = {} | |
| params['ACK'] = 'Success' | |
| params.default = [] |
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
| uhoh({"response":{"id":465,"bytes":450036,"created_at":"2012-04-22T22:24:29Z","image":{"url":"http://assets.desktoppr.co/wallpapers/3684af1ebd0380eb6acd669cf87ef9eb1e31c122/20080502_3dz_wallpapers_ru_vtorzhenie_2_1280x1024__130529_wp.jpg","thumb":{"url":"http://assets.desktoppr.co/wallpapers/3684af1ebd0380eb6acd669cf87ef9eb1e31c122/thumb_20080502_3dz_wallpapers_ru_vtorzhenie_2_1280x1024__130529_wp.jpg"},"preview":{"url":"http://assets.desktoppr.co/wallpapers/3684af1ebd0380eb6acd669cf87ef9eb1e31c122/preview_20080502_3dz_wallpapers_ru_vtorzhenie_2_1280x1024__130529_wp.jpg"}},"height":1024,"width":1280,"user_id":26,"user_count":5,"views_count":8}}) |
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
| uhoh({"response":{"id":465,"bytes":450036,"created_at":"2012-04-22T22:24:29Z","image":{"url":"http://assets.desktoppr.co/wallpapers/3684af1ebd0380eb6acd669cf87ef9eb1e31c122/20080502_3dz_wallpapers_ru_vtorzhenie_2_1280x1024__130529_wp.jpg","thumb":{"url":"http://assets.desktoppr.co/wallpapers/3684af1ebd0380eb6acd669cf87ef9eb1e31c122/thumb_20080502_3dz_wallpapers_ru_vtorzhenie_2_1280x1024__130529_wp.jpg"},"preview":{"url":"http://assets.desktoppr.co/wallpapers/3684af1ebd0380eb6acd669cf87ef9eb1e31c122/preview_20080502_3dz_wallpapers_ru_vtorzhenie_2_1280x1024__130529_wp.jpg"}},"height":1024,"width":1280,"user_id":26,"user_count":5,"views_count |
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 AddressBook | |
| attr_accessor :contacts | |
| def initialize | |
| @contacts = {} | |
| end | |
| def numbers *names | |
| names.map do |name| | |
| @contacts[name] |
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
| def store store, &block | |
| begin | |
| original = Thread.current[:store] | |
| Thread.current[:store] = store | |
| yield | |
| ensure | |
| Thread.current[:store] = original | |
| 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
| # I've noticed we want to do two different things when something about a model | |
| # changes. Typically you would use ActiveModel::Observers, but the callbacks you | |
| # get only have limited context forcing us to save more state to get it back later. | |
| # | |
| # The idea of this is that we can craft our own callbacks using a pub/sub pattern | |
| # and pass in as much transient context as we want. We also want to bring in our | |
| # analytics (or kiss metrics) on some of these callbacks. | |
| # | |
| # We can make our tests faster because we only care that our controller published | |
| # the notification. Other tests will catch who is subscribed and what they should |
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 Publishers | |
| class HTTP | |
| attr_accessor :key | |
| attr_reader :hosts | |
| def initialize attributes = nil | |
| attributes ||= {} | |
| self.event = attributes[:event] | |
| self.hosts = attributes.fetch(:hosts) do |