Reputation: 187
I just tried to deal with iCalendar gem, but it seems iCalendar has a class named Event
, and my app also have a class named Event
I guess there is a way to scope one or another class name, but i just don't know how.
Here's an example of what i'd like to do :
Event.new
=> ActiveRecord Model
Icalendar::Event.new
=> Icalendar Event class
Thank you.
Upvotes: 1
Views: 377
Reputation: 9457
Force ruby to look for top-level class definitions when accessing your model, via ::Event.new
. Including :: before class name signifies that class is not in any module, as opposed to Icalendar::Event
that is in Icalendar
module.
Or, if iCalendar does not provide the namespace, you can do it for your class, defining it as
module MyStuff
class Event
end
end
and using MyStuff::Event
for your model, and ::Event
for iCal one.
Upvotes: 0
Reputation: 66857
Hoe about wrapping up the iCalendar
gem in a module and then instantiating from e.g. Icalendar::CalEvent
or something?
require 'icalendar'
module Icalendar
CalEvent = Event
end
BTW: you could just use the name Event
, but there will be a warning about reassigning to a constant.
Upvotes: 1