Sha256: 882084ed0b97521b055d4e68c5784618c469203586c37423ff978c7194804dd7

Contents?: true

Size: 512 Bytes

Versions: 6

Compression:

Stored size: 512 Bytes

Contents

module Graphdb
  module Model
    class Address < ActiveNodeBase
      property :address, index: :exact

      has_many :in, :outputs, origin: :addresses, model_class: 'Graphdb::Model::TxOut'

      validates :address, presence: true

      scope :with_address, -> (address){where(address: address)}

      def self.find_or_create(address)
        a = with_address(address).first
        unless a
          a = new
          a.address = address
          a.save!
        end
        a
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bitcoin2graphdb-0.3.9 lib/graphdb/model/address.rb
bitcoin2graphdb-0.3.8 lib/graphdb/model/address.rb
bitcoin2graphdb-0.3.7 lib/graphdb/model/address.rb
bitcoin2graphdb-0.3.6 lib/graphdb/model/address.rb
bitcoin2graphdb-0.3.5 lib/graphdb/model/address.rb
bitcoin2graphdb-0.3.4 lib/graphdb/model/address.rb