class Errol::Entity
Constants
- NilRecord
- RepositoryUndefined
Attributes
record[R]
Public Class Methods
boolean_accessor(*entries)
click to toggle source
# File lib/errol/entity.rb, line 42 def self.boolean_accessor(*entries) boolean_query *entries entry_writer *entries end
boolean_query(*entries)
click to toggle source
# File lib/errol/entity.rb, line 29 def self.boolean_query(*entries) entries.each do |entry| define_method "#{entry}?" do !!(record.public_send entry) end end end
entry_accessor(*entries)
click to toggle source
# File lib/errol/entity.rb, line 37 def self.entry_accessor(*entries) entry_reader *entries entry_writer *entries end
entry_reader(*entries)
click to toggle source
# File lib/errol/entity.rb, line 13 def self.entry_reader(*entries) entries.each do |entry| define_method entry do record.public_send entry end end end
entry_writer(*entries)
click to toggle source
# File lib/errol/entity.rb, line 21 def self.entry_writer(*entries) entries.each do |entry| define_method "#{entry}=" do |value| record.public_send "#{entry}=", value end end end
new(record)
click to toggle source
# File lib/errol/entity.rb, line 47 def initialize(record) # raise NilRecord, "Tried to initialise #{self.class.name} with nil record" if record.nil? @record = record end
repository()
click to toggle source
# File lib/errol/entity.rb, line 9 def self.repository @repository || (raise RepositoryUndefined, "No repository set for #{self.name}") end
repository=(repository)
click to toggle source
# File lib/errol/entity.rb, line 5 def self.repository=(repository) @repository = repository end
Public Instance Methods
==(other)
click to toggle source
# File lib/errol/entity.rb, line 87 def ==(other) other.class == self.class && other.record == record end
Also aliased as: eql?
destroy()
click to toggle source
# File lib/errol/entity.rb, line 77 def destroy repository.remove self self end
refresh()
click to toggle source
# File lib/errol/entity.rb, line 82 def refresh repository.refresh self self end
repository()
click to toggle source
# File lib/errol/entity.rb, line 68 def repository self.class.repository end
save()
click to toggle source
# File lib/errol/entity.rb, line 72 def save repository.save self self end
set(**attributes)
click to toggle source
# File lib/errol/entity.rb, line 56 def set(**attributes) attributes.each do |attribute, value| self.public_send "#{attribute}=", value end self end
set!(*args)
click to toggle source
# File lib/errol/entity.rb, line 63 def set!(*args) set(*args) save end