Class: Linkage::Functions::Binary

Inherits:
Linkage::Function show all
Defined in:
lib/linkage/functions/binary.rb

Constant Summary

Constants inherited from Data

Data::TYPE_CONVERSION_TREE

Instance Attribute Summary

Attributes inherited from Linkage::Function

#args

Attributes inherited from Data

#dataset, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Linkage::Function

#==, [], #collation, #dataset, #dataset=, #initialize, #name, register, #static?

Methods inherited from Data

#collation, #database_type, #initialize, #merge, #static?

Constructor Details

This class inherits a constructor from Linkage::Function

Class Method Details

.function_nameObject



4
5
6
# File 'lib/linkage/functions/binary.rb', line 4

def self.function_name
  "binary"
end

.parametersObject



8
9
10
# File 'lib/linkage/functions/binary.rb', line 8

def self.parameters
  [[String]]
end

Instance Method Details

#ruby_typeObject



12
13
14
# File 'lib/linkage/functions/binary.rb', line 12

def ruby_type
  {:type => File}
end

#to_expr(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/linkage/functions/binary.rb', line 16

def to_expr(options = {})
  expr =
    case dataset.database_type
    when :sqlite
      @values[0].cast(:blob)
    when :postgres
      @values[0].cast(:bytea)
    else
      @values[0].cast(:binary)
    end
end