module ActiveRecord::Tableless::SingletonMethods

Public Instance Methods

add_columns(sql_type, *args) click to toggle source

Register a set of columns with the same SQL type

# File lib/activerecord-tableless.rb, line 101
def add_columns(sql_type, *args)
  args.each do |col|
    column col, sql_type
  end
end
all(*args) click to toggle source
# File lib/activerecord-tableless.rb, line 127
def all(*args)
  case tableless_options[:database]
  when :pretend_success
    []
  when :fail_fast
    raise NoDatabase.new("Can't #find_every on Tableless class")
  end

end
column(name, sql_type = nil, default = nil, null = true) click to toggle source
# File lib/activerecord-tableless.rb, line 91
def column(name, sql_type = nil, default = nil, null = true)
  tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, Type::Value.new, sql_type.to_s, null)
end
columns() click to toggle source

Return the list of columns registered for the model. Used internally by ActiveRecord

# File lib/activerecord-tableless.rb, line 84
def columns
  tableless_options[:columns]
end
destroy(*args) click to toggle source
# File lib/activerecord-tableless.rb, line 107
def destroy(*args)
  case tableless_options[:database]
  when :pretend_success
    self.new()
  when :fail_fast
    raise NoDatabase.new("Can't #destroy on Tableless class")
  end
end
destroy_all(*args) click to toggle source
# File lib/activerecord-tableless.rb, line 116
def destroy_all(*args)
  case tableless_options[:database]
  when :pretend_success
    []
  when :fail_fast
    raise NoDatabase.new("Can't #destroy_all on Tableless class")
  end
end
find_by_sql(*args) click to toggle source
# File lib/activerecord-tableless.rb, line 137
def find_by_sql(*args)
  case tableless_options[:database]
  when :pretend_success
    []
  when :fail_fast
    raise NoDatabase.new("Can't #find_by_sql on Tableless class")
  end

end
table_exists?() click to toggle source
# File lib/activerecord-tableless.rb, line 164
def table_exists?
  false
end
tableless?() click to toggle source
# File lib/activerecord-tableless.rb, line 160
def tableless?
  true
end
transaction() { || ... } click to toggle source
# File lib/activerecord-tableless.rb, line 150
      def transaction(&block)
#        case tableless_options[:database]
#        when :pretend_success
          @_current_transaction_records ||= []
          yield
#        when :fail_fast
#          raise NoDatabase.new("Can't #transaction on Tableless class")
#        end
      end