Sha256: d04ce06d9e9b99c4b9a4b44db3badea67d2259ca0cd5a9950bc7e137648cdf9c

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 Bytes

Contents

module RubyLess
  class ColumnMock
    def initialize(opts = {})
      @opts = opts
    end

    def default
      @opts[:default]
    end

    def text?
      @opts[:text]
    end

    def number?
      @opts[:number]
    end
  end

  class ActiveRecordMock
    COLUMNS = {
      'format' => ColumnMock.new(:default => '%d.%m.%Y', :text   => true),
      'age'    => ColumnMock.new(:default => 5,  :number => true),
      'friend_id' => ColumnMock.new(:number => true),
      'log_at' => ColumnMock.new,
    }
    def self.columns_hash
      COLUMNS
    end
    
    COLUMNS.each do |k, v|
      define_method(k) do
        v.default
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubyless-0.3.0 test/mock/active_record_mock.rb
rubyless-0.2.0 test/mock/active_record_mock.rb