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
[1,2].method(:many?).source_location |
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 'sinatra/base' | |
require 'jsonify/tilt' | |
class JsonifySinatra < Sinatra::Base | |
helpers do | |
def jsonify(*args) render(:jsonify, *args) end | |
end | |
get '/' do | |
jsonify :index |
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 Child | |
attr_accessor :id | |
def initialize(id) | |
@id = id | |
end | |
end | |
kids = [Child.new(2), Child.new(4)] | |
results = [{:id=>3,:kids => kids}] |
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 ActiveModel | |
module MassAssignmentSecurity | |
module Sanitizer | |
protected | |
def warn!(attrs) | |
raise "ERROR: Can't mass-assign protected attributes: #{attrs.join(', ')}" | |
end | |
end | |
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
p=Harmony::Page.new(<<-HTML | |
<html><head><title>T</title></head><body></body></html> | |
HTML | |
) | |
p.execute_js("document.write('foo')") |
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 'cucumber/rake/task' | |
namespace :cucumber do | |
Cucumber::Rake::Task.new(:webrat) do |t| | |
t.fork = true # Explicitly fork for cucumber 0.3.4 and rails | |
t.cucumber_opts = "--format progress" | |
t.step_list = %w{features/support/env.rb features/support/webrat.rb features/step_definitions} | |
t.feature_list = %w{features/webrat} | |
end | |
task :webrat => 'db:test:prepare' |
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 SearchResult | |
attr_reader :title, :abstract, :click_url, :display_url, :date | |
def initialize(result) | |
@title = result.title | |
@abstract = result.abstract | |
@click_url = result.clickurl | |
@display_url = result.dispurl | |
@date = result.date | |
end | |