Class: Transform

Inherits:
Object
  • Object
show all
Defined in:
app/transforms/transform.rb

Direct Known Subclasses

ColumnFilter, MovingAverage

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, settings) ⇒ Transform

Returns a new instance of Transform.



16
17
18
19
# File 'app/transforms/transform.rb', line 16

def initialize(table, settings)
  self.table = table
  self.settings = (settings || {}).symbolize_keys
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



15
16
17
# File 'app/transforms/transform.rb', line 15

def settings
  @settings
end

#tableObject

Returns the value of attribute table.



14
15
16
# File 'app/transforms/transform.rb', line 14

def table
  @table
end

Class Method Details

.display_nameObject



7
8
9
# File 'app/transforms/transform.rb', line 7

def self.display_name
  name.demodulize.underscore.humanize.titleize
end

.form_keysObject



10
11
12
# File 'app/transforms/transform.rb', line 10

def self.form_keys
  [:columns]  # override to get more / different
end

.transformsObject



2
3
4
5
# File 'app/transforms/transform.rb', line 2

def self.transforms
  DailyConfig.load_classes if Rails.env.development?
  subclasses
end

Instance Method Details

#columnsObject



26
27
28
# File 'app/transforms/transform.rb', line 26

def columns
  setting(:columns, []).collect(&:to_s)
end

#resultObject



30
31
32
# File 'app/transforms/transform.rb', line 30

def result
  raise("Transforms must override result")
end

#setting(key, default = nil) ⇒ Object



21
22
23
24
# File 'app/transforms/transform.rb', line 21

def setting(key, default = nil)
  val = settings[key.to_sym]
  val.blank? ? default : val
end