Bruno
Bruno

Reputation: 6449

How do I call a method from a class in a ruby gem?

How do I call a method from a class in a ruby gem?

i.e.

gem install mindbody

In the gem's documentation, I see various classes. But no guideline on how to call these classes from code.

For example, I'd like to call a method in the ClassService class.

Upvotes: 0

Views: 2076

Answers (1)

vlain
vlain

Reputation: 712

For MindBody look at root Module Mb.

You can list all types declared using:

require 'rubygems'
require 'mindbody'
Mb.constants

It gives you:

["AppointmentService", "SourceCredentials", "Meta", "StaffService", "Options", "SiteService", "StaffOptions", "Credentials", "ClientService", "ClassService", "SaleService", "Service"]

After you can call Mb::ClassService.new or include Mb; ClassService.new

A little bit of metaprogramming for you

Upvotes: 2

Related Questions