Class: Joint::AttachmentProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/joint/attachment_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance, name) ⇒ AttachmentProxy

Returns a new instance of AttachmentProxy.



3
4
5
# File 'lib/joint/attachment_proxy.rb', line 3

def initialize(instance, name)
  @instance, @name = instance, name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



32
33
34
# File 'lib/joint/attachment_proxy.rb', line 32

def method_missing(method, *args, &block)
  grid_io.send(method, *args, &block)
end

Instance Method Details

#grid_ioObject



28
29
30
# File 'lib/joint/attachment_proxy.rb', line 28

def grid_io
  @grid_io ||= @instance.grid.get(id)
end

#idObject



7
8
9
# File 'lib/joint/attachment_proxy.rb', line 7

def id
  @instance.send("#{@name}_id")
end

#nameObject



11
12
13
# File 'lib/joint/attachment_proxy.rb', line 11

def name
  @instance.send("#{@name}_name")
end

#nil?Boolean Also known as: blank?

Returns:

  • (Boolean)


23
24
25
# File 'lib/joint/attachment_proxy.rb', line 23

def nil?
  !@instance.send("#{@name}?")
end

#sizeObject



15
16
17
# File 'lib/joint/attachment_proxy.rb', line 15

def size
  @instance.send("#{@name}_size")
end

#typeObject



19
20
21
# File 'lib/joint/attachment_proxy.rb', line 19

def type
  @instance.send("#{@name}_type")
end