Sha256: f607fb219e611e0c879733d4b87344035965c936df3f53c22146c45f13fdd213

Contents?: true

Size: 912 Bytes

Versions: 6

Compression:

Stored size: 912 Bytes

Contents

class <%= class_name %>
  include ApacheAge::Entities::Edge

<%- attributes_list.each do |attribute| -%>
  attribute :<%= attribute[:name] %>, :<%= attribute[:reference] || attribute[:type] %>
<%- end -%>
  # recommendation for (start_node and end_node): change `:node` with the actual 'node' type
  # see `config/initializers/apache_age.rb` for the list of available node types
  attribute :start_node
  attribute :end_node

<%- attributes_list.each do |attribute| -%>
  validates :<%= attribute[:name] %>, presence: true
<%- end -%>
  validates :start_node, presence: true
  validates :end_node, presence: true

  validate :validate_unique_edge

  private

  # custom unique edge validator (remove any attributes that are NOT important to uniqueness)
  def validate_unique_edge
    ApacheAge::Validators::UniqueEdge
      .new(attributes: <%= unique_edge_attributes.inspect %>)
      .validate(self)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_age-0.6.4 lib/generators/apache_age/edge/templates/edge.rb.tt
rails_age-0.6.3 lib/generators/apache_age/edge/templates/edge.rb.tt
rails_age-0.6.2 lib/generators/apache_age/edge/templates/edge.rb.tt
rails_age-0.6.1 lib/generators/apache_age/edge/templates/edge.rb.tt
rails_age-0.6.0 lib/generators/apache_age/edge/templates/edge.rb.tt
rails_age-0.5.3 lib/generators/apache_age/edge/templates/edge.rb.tt