fiedl/your_platform

View on GitHub
app/models/concerns/dag_link_types.rb

Summary

Maintainability
A
25 mins
Test Coverage
concern :DagLinkTypes do

  included do
    before_validation :change_type_according_to_other_attributes
  end

  def change_type_according_to_other_attributes
    self.type = "Membership" if ancestor_type == "Group" and descendant_type == "User"
    self.type = "Memberships::Status" if self.type == "Membership" and ancestor.kind_of?(StatusGroup)
  end

end