class ChefFixie::Sql::SqlObject
we declare these first so that the 'element' metaprogramming in SqlTable
works
Public Class Methods
name_field(field)
click to toggle source
TODO figure out model for write access
# File lib/chef_fixie_shahid/sql_objects.rb, line 103 def self.name_field(field) fundef = "def name; @data.#{field}; end" class_eval(fundef) end
new(data)
click to toggle source
# File lib/chef_fixie_shahid/sql_objects.rb, line 82 def initialize(data) @data = data end
ro_access(*args)
click to toggle source
TODO rework this to use better style
# File lib/chef_fixie_shahid/sql_objects.rb, line 95 def self.ro_access(*args) args.each do |field| fundef = "def #{field}; @data.#{field}; end" class_eval(fundef) end end
std_authz()
click to toggle source
Pretty much any object with an authz id has these fields
# File lib/chef_fixie_shahid/sql_objects.rb, line 115 def self.std_authz std_timestamp [:authz_id, :last_updated_by].each do |i| ro_access(i) end end
std_timestamp()
click to toggle source
# File lib/chef_fixie_shahid/sql_objects.rb, line 108 def self.std_timestamp [:created_at, :updated_at].each do |i| ro_access(i) end end
Public Instance Methods
data()
click to toggle source
# File lib/chef_fixie_shahid/sql_objects.rb, line 86 def data @data end
delete()
click to toggle source
# File lib/chef_fixie_shahid/sql_objects.rb, line 122 def delete rows = table.by_id(id) raise "id #{id} matches more than one object" if rows.all.count != 1 rows.inner.delete if respond_to?(:authz_delete) authz_delete end end
table()
click to toggle source
# File lib/chef_fixie_shahid/sql_objects.rb, line 90 def table Relationships.table_class(self).new end