L
Lipper, Matthew
Hey everybody,
Given the following extension to the Date class:
class Date
attr_accessor :date_precision
class << self; alias_method ld_civil, :civil end
def self.civil(*args)
#How to make this visible?
@date_precision = args.shift
puts "#{@date_precision}" if($VERBOSE) # >> DAY_OF_MONTH
return old_civil(*args)
end
end
date = Date.civil("DAY_OF_MONTH",2004,2,5)
#Doh!
puts date.date_precision # >> nil
What is the proper syntax to make the date_precision attribute visible to
the caller? I'm still trying to wrap my head around the notion of open
classes and extending object instances...
Matt
Given the following extension to the Date class:
class Date
attr_accessor :date_precision
class << self; alias_method ld_civil, :civil end
def self.civil(*args)
#How to make this visible?
@date_precision = args.shift
puts "#{@date_precision}" if($VERBOSE) # >> DAY_OF_MONTH
return old_civil(*args)
end
end
date = Date.civil("DAY_OF_MONTH",2004,2,5)
#Doh!
puts date.date_precision # >> nil
What is the proper syntax to make the date_precision attribute visible to
the caller? I'm still trying to wrap my head around the notion of open
classes and extending object instances...
Matt