Sha256: 16e97c11f2ea7b61140a42d9718a1721c944dee81ae8110f8acd0b9fe0d056d5

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require "db_diagram/version"
require "active_support/ordered_options"

#   DBDiagram.options.orientation = :vertical
#   DBDiagram.options.title = "My model diagram"
module DBDiagram
  class Error < StandardError; end

  class << self
    # Access to default options. Any instance of DBDiagram::Domain and
    # DBDiagram::Diagram will use these options unless overridden.
    attr_accessor :options

    def default_options
      ActiveSupport::OrderedOptions[
        :attributes, :true, #显示全部字段,调用Attribute#true?
        :filename, nil, #nil时文件名为数据库名
        :filetype, :png,
        :markup, true,
        :notation, :simple, #显示式样
        :orientation, :horizontal, #排列方向,横向
        :sort, false, #字段不排序
        :warn, true,
        :title, true,
        :exclude, nil, #不显示的表名,例:[:admins, users]
        :only, nil, #只显示的表名,例:[:admins, users]
        :only_recursion_depth, nil,
        :prepend_primary, true, #把主键放在最前面
        :cluster, false,
      ]
    end
  end

  module Inspectable # @private :nodoc:
    def inspection_attributes(*attributes)
      attribute_inspection = attributes.collect { |attribute|
        " @#{attribute}=\#{[Symbol, String].include?(#{attribute}.class) ? #{attribute}.inspect : #{attribute}}"
      }.join
      class_eval <<-RUBY
        def inspect
          "#<\#{self.class}:0x%.14x#{attribute_inspection}>" % (object_id << 1)
        end
      RUBY
    end
  end

  self.options = default_options #.merge(Config.load)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
db_diagram-0.1.0 lib/db_diagram.rb