Module: WPDB::GravityForms

Defined in:
lib/ruby-wpdb/gravityforms.rb

Defined Under Namespace

Classes: Detail, DetailLong, Form, FormMeta, Lead, ModelGenerator

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

When a request is made to, for example, WPDB::GravityForms::SomeClass, this method will fire. If there’s a GravityForm whose title, when camelised, is “SomeClass”, a model will be created for that form.

After the first time, the constant for that form will have been created, and so this hook will no longer fire.



178
179
180
181
182
183
184
185
186
187
# File 'lib/ruby-wpdb/gravityforms.rb', line 178

def self.const_missing(name)
  Form.each do |form|
    if name.to_s == WPDB.camelize(form.title)
      ModelGenerator.new(form).generate
      return WPDB::GravityForms.const_get(name)
    end
  end

  raise "Form not found: #{name}"
end