Skip to content

Instantly share code, notes, and snippets.

@kematzy
Created March 5, 2009 06:03
Show Gist options
  • Save kematzy/74225 to your computer and use it in GitHub Desktop.
Save kematzy/74225 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra/base'
module Sinatra
module AttrAccessorBug
# NB!! Using attr_accessor causes this error:
#
# SyntaxError: compile error (__DELEGATE__):2: syntax error, unexpected ',', expecting '=' ::Sinatra::Application.attr_accessor_bug_last=(*args, &b) ^
#
attr_accessor :attr_accessor_bug_first, :attr_accessor_bug_last
# Whereas attr_reader works fine
# attr_reader :attr_accessor_bug_first, :attr_accessor_bug_last
def self.registered(app)
# app.helpers AttrAccessorBug::Helpers
end
end
register(Sinatra::AttrAccessorBug)
end
# ======================
# require 'sinatra/base'
class Hello < Sinatra::Base
register Sinatra::AttrAccessorBug
get '/' do
"Hello World"
end
end
Hello.run!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment