Skip to content

Instantly share code, notes, and snippets.

@macejmic
Last active May 6, 2016 15:21
Show Gist options
  • Save macejmic/2f9b5531c9633beb806f96a728daab91 to your computer and use it in GitHub Desktop.
Save macejmic/2f9b5531c9633beb806f96a728daab91 to your computer and use it in GitHub Desktop.
diff --git a/app/events/applications/application_created_event.rb b/app/events/applications/application_created_event.rb
index 29afbca..8f62278 100644
--- a/app/events/applications/application_created_event.rb
+++ b/app/events/applications/application_created_event.rb
@@ -1,4 +1,15 @@
class Applications::ApplicationCreatedEvent < RailsEventStore::Event
+
+ def self.belongs_to(association)
+ define_method "find_#{association}" do
+ association.to_s.camelize.constantize.find(__send__("#{association}_id"))
+ end
+ end
+
+ belongs_to :provider
+ belongs_to :service
+ belongs_to :plan
+
# @param [Cinstance] application
def self.create(application)
new(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment