lib/graphdb/model/address.rb in bitcoin2graphdb-0.1.5 vs lib/graphdb/model/address.rb in bitcoin2graphdb-0.1.6
- old
+ new
@@ -1,15 +1,17 @@
module Graphdb
module Model
class Address < ActiveNodeBase
property :address, index: :exact, constraint: :unique
+ has_many :in, :outputs, origin: :addresses, model_class: TxOut
+
validates :address, presence: true
- scope :with_address, -> (address){where(address: address).first}
+ scope :with_address, -> (address){where(address: address)}
def self.find_or_create(address)
- a = with_address(address)
+ a = with_address(address).first
unless a
a = new
a.address = address
a.save!
end
\ No newline at end of file