Sha256: 0c0c9545ba8cea5cef51ddb57b7a18d067fbc98aa35b52ec5ec1f5137e08bc67
Contents?: true
Size: 888 Bytes
Versions: 2
Compression:
Stored size: 888 Bytes
Contents
module DrawSmd class Diagram class << self def schemas schemas = ActiveRecord::Base.connection.tables schemas.delete('schema_migrations') schemas.map! {|schema| schema.singularize.camelize} schemas = schemas.inject([]) { |arr, schema| arr << schema if state_machines?(schema) arr } schemas.sort end def state_machines?(schema) Object.const_get(schema).respond_to?(:state_machines) rescue false end end def initialize(path) @path = File.expand_path(path, Rails.root) FileUtils.mkdir_p(@path) end def create(title, domain) options = { path: @path, name: title } Rails.application.eager_load! StateMachine::Machine.draw(domain, options) rescue => e Rails.logger.error(e) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
draw_smd-0.1.2 | app/models/draw_smd/diagram.rb |
draw_smd-0.1.1 | app/models/draw_smd/diagram.rb |