class Dalton::Entity

Constants

DB_FUNCTION_KEY

Attributes

datomic_entity[R]

Public Class Methods

new(datomic_entity) click to toggle source
# File lib/dalton/entity.rb, line 6
def initialize(datomic_entity)
  @datomic_entity = datomic_entity
end

Public Instance Methods

==(other) click to toggle source
# File lib/dalton/entity.rb, line 53
def ==(other)
  other.instance_of?(self.class) && Utility.clojure_equal?(datomic_entity, other.datomic_entity)
end
[](key)
Alias for: get
db() click to toggle source
# File lib/dalton/entity.rb, line 12
def db
  Database.new(datomic_entity.db)
end
decode(value) click to toggle source
# File lib/dalton/entity.rb, line 57
def decode(value)
  case value
    when Dalton::Entity
      value.to_h
    when Set
      Set.new(value.map{|x| decode(x)})
    else
      Translation.from_clj(value)
  end
end
each() { |key, get(key)| ... } click to toggle source
# File lib/dalton/entity.rb, line 35
def each
  if block_given?
    keys.each do |key|
      yield [key, get(key)]
    end
    self
  else
    Enumerator.new(self)
  end
end
Also aliased as: each_pair
each_pair()
Alias for: each
fn() click to toggle source
# File lib/dalton/entity.rb, line 70
def fn
  @datomic_entity.get(DB_FUNCTION_KEY)
end
get(key) click to toggle source
# File lib/dalton/entity.rb, line 16
def get(key)
  Translation.from_clj(datomic_entity.get(Translation.from_ruby(key)))
end
Also aliased as: []
id() click to toggle source
# File lib/dalton/entity.rb, line 31
def id
  get(:'db/id')
end
keys() click to toggle source
# File lib/dalton/entity.rb, line 27
def keys
  datomic_entity.keySet.map{|x| x.sub(/^:/, '').to_sym}.to_a
end
to_h() click to toggle source
# File lib/dalton/entity.rb, line 47
def to_h
  Hash[map {|key, value|
    [key, decode(value)]
  }]
end
touch() click to toggle source
# File lib/dalton/entity.rb, line 22
def touch
  @datomic_entity.touch
  self
end