Class: Joint::AttachmentProxy

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

Instance Method Summary (collapse)

Constructor Details

- (AttachmentProxy) initialize(instance, name)

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

- (Object) method_missing(method, *args, &block)



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

- (Object) grid_io



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

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

- (Object) id



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

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

- (Object) name



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

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

- (Boolean) nil? Also known as: blank?

Returns:

  • (Boolean)


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

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

- (Object) size



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

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

- (Object) type



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

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