Skip to content

Instantly share code, notes, and snippets.

@noeticpenguin
Created August 20, 2012 11:17
Show Gist options
  • Save noeticpenguin/e02ca436ac555d319911 to your computer and use it in GitHub Desktop.
Save noeticpenguin/e02ca436ac555d319911 to your computer and use it in GitHub Desktop.
modules inheriting constants from classes that include them....
def make_get_request(restriction)
@hydra ||= ActiveCrowd::ACRest.new
[line 68] request = Typhoeus::Request.new("#{CROWD_URL}/#{SearchResource}#{restriction}", JSONGetOptions)
@hydra.queue(request)
@hydra.run
resp_hash = sanitize_crowd_results(JSON.parse(request.response.body))
resp_hash['users'].to_json
end
[6] pry(main)> f
=> #<User:0x007ff2a61075c0>
[7] pry(main)> User.ancestors
=> [User,
ActiveCrowd::User,
Object,
PP::ObjectMixin,
RSpec::Core::SharedExampleGroup,
JSON::Ext::Generator::GeneratorMethods::Object,
Kernel,
BasicObject]
[8] pry(main)> f.all
NameError: uninitialized constant CROWD_URL
from /ruby/active_crowd/lib/active_crowd/user.rb:68:in `make_get_request'
require 'active_crowd'
class User
include ActiveCrowd::User
###############################################################################
# Required Constants #
###############################################################################
#These can be loaded from a YML thusly:
# ConfigHash = YAML.load(File.read(Path/To/Yml/File))[ENV['RAILS_ENV']]
CROWD_URL = "http://10.4.0.151:8095/crowd"
CROWD_USER = "foo"
CROWD_PASS = "fighters"
end
f = User.new
binding.pry
ap f.all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment