Module: ModelProbe

Includes:
Probes
Defined in:
lib/model_probe.rb,
lib/model_probe/version.rb,
lib/model_probe/railtie.rb

Defined Under Namespace

Modules: Probes Classes: Railtie

Constant Summary collapse

VERSION =
"1.1.3"

Instance Method Summary collapse

Methods included from Probes

#probe

Methods included from Probes::Subclasses

#probe_subclasses

Methods included from Probes::Indexes

#probe_indexes

Methods included from Probes::Columns

#probe_columns

Methods included from Probes::Metadata

#probe_metadata

Instance Method Details

Prints a stub that can be used for a test fixture



13
14
15
16
17
# File 'lib/model_probe.rb', line 13

def print_fixture
  template = erb_template("model_probe/templates/fixture.yml.erb")
  puts template.result_with_hash(name: name, fixture_columns: fixture_columns)
  nil
end

Prints a new model definition based on the database schema



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/model_probe.rb', line 20

def print_model
  template = erb_template("model_probe/templates/model.rb.erb")
  puts template.result_with_hash(
    name: name,
    superclass_name: superclass.name,
    primary_key_columns: primary_key_columns,
    foreign_key_columns: foreign_key_columns,
    relation_columns: relation_columns,
    required_columns: required_columns,
    limit_columns: limit_columns,
    validation_columns: validation_columns
  )
  nil
end