Sha256: af6263144bd1bf05518f71a5d729567f74e1c3c23bffc681f15ceb03d88bbc60

Contents?: true

Size: 912 Bytes

Versions: 100

Compression:

Stored size: 912 Bytes

Contents

class ModelStub < ActiveRecord::Base
  abstract_class = true
  has_one :other_model, :class_name => 'ModelStub'
  has_many :other_models, :class_name => 'ModelStub'
  
  cattr_accessor :stubbed_columns
  self.stubbed_columns = [:a, :b, :c, :d, :id]
  attr_accessor *self.stubbed_columns

  def other_model=(val)
    @other_model = val
  end
  def other_model
    @other_model || nil
  end

  def other_models=(val)
    @other_models = val
  end
  def other_models
    @other_models || []
  end

  def self.columns
    @columns ||= self.stubbed_columns.map{|c| ActiveRecord::ConnectionAdapters::Column.new(c.to_s, '') }
  end

  def self.columns_hash
    @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name.to_s] = column; hash }
  end

  # column-level security methods, used for testing
  def self.a_authorized_for_bar?(user)
    true
  end
  def self.b_authorized?(user)
    false
  end
end

Version data entries

100 entries across 100 versions & 3 rubygems

Version Path
six-updater-web-0.23.4 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.23.3 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.23.2 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.23.1 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.23.0 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.22.4 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.22.3 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.22.2 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.22.1 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.22.0 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.6 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.5 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.4 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.3 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.2 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.1 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.21.0 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.20.8 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.20.7 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb
six-updater-web-0.20.5 lib/six-updater-web/vendor/plugins/active_scaffold/test/model_stub.rb