
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
it adds optimistic persistence support to DataMapper and ActveRecord using the updated_at property/attribute which is automatically updated on any change of the model (for datamapper you need dm-timestamps for that). to load a model use optimistic_get
/optimistic_get!
/optimistic_find
respectively where the first argument is the last updated_at
value which the client has. if the client data is uptodate then the optimistic_XYZ
method will return the database entity otherwise raise an exception or return nil respectively.
just include require 'ixtlan/datamapper/optimistic'
and have model like:
class User
include DataMapper::Resource
property :id, Serial
property :name, String
timestamps :at
end
you need the timestamps to get it to work since the updated_at property will be used to determine if the object is stale or not.
now you get the object in an optimistic manner
User.optimistic_get!( updated_at, id )
User.optimistic_get( updated_at, id )
if will raise an Ixtlan::DataMapper::StaleObjectException in case the object with the given id
exists but does carry a different updated_at timestamp. otherwise the optimistic_get
and optimistic_get!
behave the same as get
and get!
.
now you get the object in an conditional manner
User.conditinal_get!( updated_at, id )
User.conditional_get( updated_at, id )
it the User
when the updated_at does not match. when it matches it returns false
. in case the id
does not exist, it will return either nil of DataMapper::ObjectNotFoundError. this allows constructs like
if u = User.conditinal_get!( request.last_modified, id )
response.last_modified = u.updated_at
response.write ....
else
# in case request.last_modified was nil
response.last_modified = u.updated_at
end
class Group
include DataMapper::Resource
include Ixtlan::DataMapper::Immutable
property :id, Serial
property :name, String
end
you can create and delete those object but any attempt to change it the name ends in validation error.
just convenient file to setup datamapper to use UTC timestamps
the collection is virtus object which helps to transport collections of DataMapper objects around. it has the total_count
and an offset
along an accessor for the list. the contructor deals with offset and limit on the datamapper query.
class UserCollection < Ixtlan::DataMapper::Collection
attribute :users, Array[User]
def data=( d )
self.users = d
end
end
this
UserCollection.new( User.all( :name.like => 'a%' ), 20, 10 )
will return 10 users starting with 'a' starting with 20th user from all possible users (with 'a').
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)enjoy :)
FAQs
Unknown package
We found that ixtlan-datamapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.