Skip to content

Commit

Permalink
Add some more ActiveModel magic to node and relationship model.
Browse files Browse the repository at this point in the history
This will improve integration with rubyonrails tremendously. Also make
sure that we load the model extensions for the subklass and not the one
we inherit from.
  • Loading branch information
namxam committed Oct 26, 2011
1 parent a8ddbd8 commit f81d1b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/architect4r/model/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module Architect4r
module Model

class Node

#
# architect4r extensions
#
include Architect4r::Model::Connection
include Architect4r::Model::Callbacks
include Architect4r::Model::Persistency
Expand All @@ -11,6 +15,8 @@ class Node

def self.inherited(subklass)
super
subklass.send(:include, ActiveModel::Conversion)
subklass.extend ActiveModel::Naming
subklass.send(:include, Architect4r::Model::Properties)
subklass.send(:include, Architect4r::Model::Validations)

Expand Down
4 changes: 3 additions & 1 deletion lib/architect4r/model/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Model
class Relationship

#
# Extensions
# Architect4r extensions
#
include Architect4r::Model::Connection
include Architect4r::Model::Callbacks
Expand All @@ -12,6 +12,8 @@ class Relationship

def self.inherited(subklass)
super
subklass.send(:include, ActiveModel::Conversion)
subklass.extend ActiveModel::Naming
subklass.send(:include, Architect4r::Model::Properties)
subklass.send(:include, Architect4r::Model::Validations)

Expand Down

0 comments on commit f81d1b2

Please sign in to comment.