Skip to content

Instantly share code, notes, and snippets.

# fixes deserialization from xml with nested associations
# based on http://www.xcombinator.com/2008/08/11/activerecord-from_xml-and-from_json-part-2/
module ActiveRecord #:nodoc:
module Serialization
def from_hash( hash )
h = hash.dup
h.each do |key,value|
case value.class.to_s
class Salute
attr_writer :stalutation
def show_salutation(sender)
@stalutation.stringValue = "Hi MacRuby!"
end
end
require 'hotcocoa'
include HotCocoa
application do
window = window(title: 'Hello World', frame: [0,0,200,60])
label = label(text:'Hello World', layout: {align: :center})
window << label
end
framework 'Cocoa'
app = NSApplication.sharedApplication
window = NSWindow.alloc.initWithContentRect([0,0,200,60],
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask ,
backing:NSBackingStoreBuffered,
defer:false)
describe "store localized date strings" do
class User < ActiveRecord::Base
end
it "should store a german date string" do #failing
user = User.create! :date_of_birth => '20.12.1980'
user.date_of_birth.should == Date.parse('1980-12-20')
end
it "should store a international date string" do
<%= _("${TM_SELECTED_TEXT/"/\\"/g}") %> #rails gettext snippet for HTML text
_("${TM_SELECTED_TEXT/"/\\"/g}") #rails gettext snippet for ruby strings
To use same shortcut for both scope them a following
text.html.ruby #for html
string.quoted.single.ruby|string.quoted.double.ruby #for ruby strings