Sha256: 81829e29f47eea6a3318e489814f9a79a5f38f9f521980f91aa74da65f203af3

Contents?: true

Size: 544 Bytes

Versions: 4

Compression:

Stored size: 544 Bytes

Contents

module ExportTo
  class Presenter
    attr_accessor :model, :relation, :x, :y
    NoAttributeError = Class.new(NoMethodError)

    def initialize(model, relation=nil, x, y)
      self.model, self.relation = model, relation
      self.x, self.y = x, y
    end

    def relation?
      relation.present?
    end

    def method_missing(m, *args, &block)
      obj = relation.respond_to?(m) ? relation : model
      if block_given?
        obj.public_send(m, *args, &block)
      else
        obj.public_send(m, *args)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
export_to-1.1.0 lib/export_to/presenter.rb
export_to-1.0.0 lib/export_to/presenter.rb
export_to-0.1.2 lib/export_to/presenter.rb
export_to-0.1.1 lib/export_to/presenter.rb