lib/ronin/arch.rb in ronin-0.1.2 vs lib/ronin/arch.rb in ronin-0.1.3
- old
+ new
@@ -1,11 +1,11 @@
#
#--
# Ronin - A Ruby platform designed for information security and data
# exploration tasks.
#
-# Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
+# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@@ -23,15 +23,19 @@
require 'ronin/extensions/meta'
require 'ronin/extensions/string'
require 'ronin/model'
+require 'dm-predefined'
+
module Ronin
class Arch
include Model
+ include DataMapper::Predefined
+ # Primary key
property :id, Serial
# Name of the architecture
property :name, String
@@ -58,23 +62,11 @@
#
# Defines a new builtin Arch with the specified _name_ and the given
# _options_.
#
- def Arch.define(name,options={})
- name = name.to_s
- endian = options[:endian].to_s
- address_length = options[:address_length].to_i
-
- meta_def(name.to_method_name) do
- Arch.first_or_create(
- :name => name,
- :endian => endian,
- :address_length => address_length
- )
- end
-
- return nil
+ def self.define(name,options={})
+ super(name,options.merge(:name => name))
end
define :i386, :endian => :little, :address_length => 4
define :i486, :endian => :little, :address_length => 4
define :i686, :endian => :little, :address_length => 4