Pros
- Familar
- Clean abstraction from model
- No model changes required
Cons
- Slow, 2N loading with cassandra-driver
class Person
attr_accessor :name
def initialize(opts={})
@name = opts[:name]
end
end
Person.new(name: "eprothro")
or when loading from a hash
p = Person.new
p.name = row["name"]
becomes
class Person
include DataState
data_attr :name
end
Person.new(name: "eprothro")
or when loading from a hash
p = Person.new(TableAdapater.new(row))
Pros
- Fast, almost zero overhead added to cassandra-driver
- Easy serialization
- No public interface change
- Easy to raise if state unknown (from selection without attr)
Cons
- Not idiomatic
- More code, code relations twice (data model, model model)
- Complexity around contained non-primitives
- Requires change to modeling
- Theoretical muddiness with persisted-attributes concept in model