8000 GitHub - coderberry/model_probe: Schema introspection for ActiveModel
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

coderberry/model_probe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ModelProbe

Schema introspection for ActiveRecord

Provides a detailed view of the underlying schema that backs an ActiveRecord model.

This functionality can be added to any object that implements ActiveRecord's columns interface.

Installation

Add this line to your application's Gemfile:

gem 'model_probe'

And then execute:

$ bundle

Or install it yourself as:

$ gem install model_probe

Usage

MyModel.extend ModelProbe
MyModel.probe
MyModel.print_fixture
MyModel.print_model

Rails Integration

Create config/initializers/model_probe.rb

ActiveRecord::Base.extend ModelProbe if Rails.env.development?

Rake Task

Create lib/tasks/model.rake

namespace :model do
  desc <<~DESC
    Print model. Usage: `rails model:probe[User]`
  DESC
  task :probe, [:klass] => :environment do |task, args|
    klass = args.klass
    puts klass.constantize.print_model
  end
end

About

Schema introspection for ActiveModel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%
0