in the following code I am running into an error which states syntax error, unexpected '\n', expecting :: or '[' or '.' (SyntaxError)
But I don't see where the issue is.
module Xaaron
class ApiKey.class_eval # It does not like this....
include Promiscuous::Publisher
publish :xaaron_users_id, :api_key, :as => :ApiKey
end
end
Am I using class_eval
wrong?
You can either remove the class
keyword, and add do
after calling class_eval
(passing it a block):
module Xaaron
ApiKey.class_eval do
include Promiscuous::Publisher
publish :xaaron_users_id, :api_key, :as => :ApiKey
end
end
(given that ApiKey
already exists)
OR you can remove the class_eval
altogether:
module Xaaron
class ApiKey
include Promiscuous::Publisher
publish :xaaron_users_id, :api_key, :as => :ApiKey
end
end
This will work even if the ApiKey
already exists... that's just the way ruby works...