Sha256: 7f408bdadfe412b3ec99437fbd352807ffa8f09a39608dfda8bb72fda5a7dd0d
Contents?: true
Size: 844 Bytes
Versions: 5
Compression:
Stored size: 844 Bytes
Contents
module Host def self.method_missing(method, *args, &block) type = "Host::Managed" case method.to_s when /create/, 'new' if args.empty? or args[0].nil? # got no parameters #set the default type args = [{:type => type}] else # got some parameters args[0][:type] ||= type # adds the type if it doesnt exists type = args[0][:type] # stores the type for later usage. end end type.constantize.send(method,*args, &block) end # the API base controller expects to call 'respond_to?' on this, which # this module doesn't have. So we stub it out to make that logic work for # the "find_by_*" classes that Rails will provide def self.respond_to?(method, include_private = false) if method.to_s =~ /^find_by_(.*)$/ true else super end end end
Version data entries
5 entries across 5 versions & 1 rubygems