Sha256: b7f26ec252cb390de7002e358897db8b5590452ecab4dc1da5f5ab108671fd65

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

class Tabulatr::DummyRecord

  def self.for(klaz)
    c = Class.new(self)
    c.instance_variable_set("@model_name", klaz.model_name)
    c.new
  end

  def to_s
    @methods ||= []
    if @methods.any?
      m = @methods.join(':')
      @method_names ||= []
      @method_names << m
      @methods.clear
      "{{#{m}}}"
    else
      "{{id}}"
    end
  end

  def method_missing(sym, *args)
    @methods ||= []
    @methods << sym.to_s
    self
  end

  def to_key
    ["{{id}}"]
  end

  def requested_methods
    Array(@method_names).try(:uniq)
  end

  def self.model_name
    @model_name
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabulatr2-0.6.0 lib/tabulatr/tabulatr/dummy_record.rb