Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing subclass transitions #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class Job
end
end

job = Job.new

AASMDiagram::Diagram.new(job.aasm, 'docs/job.png')
AASMDiagram::Diagram.new(Job.aasm, 'docs/job.png')
```

Generates the following diagram:
Expand Down Expand Up @@ -130,8 +128,7 @@ class Cleaner
end
end

cleaner = Cleaner.new
AASMDiagram::Diagram.new(job.aasm, '../docs/guard-cleaner.png')
AASMDiagram::Diagram.new(Cleaner.aasm, '../docs/guard-cleaner.png')
```

![Diagram of Cleaner state machine](docs/guard-cleaner.png)
Expand Down Expand Up @@ -170,9 +167,8 @@ class SimpleMultipleExample
end
end

simple = SimpleMultipleExample.new
AASMDiagram::Diagram.new(simple.aasm(:move), 'docs/multiple-state-machines-1.png')
AASMDiagram::Diagram.new(simple.aasm(:work), 'docs/multiple-state-machines-2.png')
AASMDiagram::Diagram.new(SimpleMultipleExample.aasm(:move), 'docs/multiple-state-machines-1.png')
AASMDiagram::Diagram.new(SimpleMultipleExample.aasm(:work), 'docs/multiple-state-machines-2.png')
```

Generates two images:
Expand Down
2 changes: 1 addition & 1 deletion lib/aasm_diagram/diagram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def state_names
end

def events
@aasm_instance.events.first.state_machine.events.values
@aasm_instance.events
end
end
end
4 changes: 1 addition & 3 deletions lib/aasm_diagram/tasks/generate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ namespace :'aasm-diagram' do

smn = args[:smn]&.to_sym

model_instance = model_klass.new

output_dir = ENV.fetch('AASM_DIAGRAM_OUTPUT_DIR') { './tmp' }
output = File.join([output_dir, "#{args[:model]}-#{args[:smn] || 'default'}.png"])

AASMDiagram::Diagram.new(
smn && model_instance.aasm(smn) || model_instance.aasm,
smn && model_klass.aasm(smn) || model_klass.aasm,
output
)
end
Expand Down