Sha256: c097deebf324a7e8b22b9716ed65c91b0631db7800df127a48ee7fa89670846f
Contents?: true
Size: 971 Bytes
Versions: 1
Compression:
Stored size: 971 Bytes
Contents
# encoding: UTF-8 class PryRails::ShowModel < Pry::ClassCommand match "show-model" group "Rails" description "Show the given model." def options(opt) opt.banner unindent <<-USAGE Usage: show-model <model name> show-model displays one model from the current Rails app. USAGE end def process Rails.application.eager_load! if args.empty? output.puts opts return end begin model = Object.const_get(args.first) rescue NameError output.puts "Couldn't find model #{args.first}!" return end formatter = PryRails::ModelFormatter.new case when model < ActiveRecord::Base output.puts formatter.format_active_record(model) when defined?(Mongoid::Document) && model < Mongoid::Document output.puts formatter.format_mongoid(model) else output.puts "Don't know how to show #{model}!" end end end PryRails::Commands.add_command PryRails::ShowModel
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pry-rails-0.3.2 | lib/pry-rails/commands/show_model.rb |