I have this class:
class Option
# ORM's properties
def self.get( id )
# some ORM action
"result of #{id}"
end
end
And I can call Option.get :setting to receive a result. How do I write the class if I want to call Option(:setting) like in String(42) (which returns "42") to get the same result as Option#get?
Stringis actually a method in the Kernel module:You’ll find
Array,Float, and friends in the same place. Kernel is included in Object and that’s where all the methods that are used like plain global functions go. You could monkey patch Kernel:Or make your own module with a method like that and make people include it if they want access to say
Option(11).