Class: Rubiks::Measure

Inherits:
NamedObject show all
Defined in:
lib/rubiks/measure.rb

Instance Method Summary collapse

Methods inherited from NamedObject

[], #caption, clear!, default, #default_json_attributes, #default_xml_attributes, define, #description, find_or_create, #hidden, #icon_type, #initialize, instances, #name, #table, #table_with_prefix, #to_json

Constructor Details

This class inherits a constructor from Rubiks::NamedObject

Instance Method Details

#aggregator(new_name = nil, options = {}) ⇒ Object



9
10
11
12
# File 'lib/rubiks/measure.rb', line 9

def aggregator(new_name=nil, options={})
  @aggregator = new_name.to_s if new_name.present?
  @aggregator ||= @options[:aggregator] || 'count'
end

#column(new_name = nil, options = {}) ⇒ Object



4
5
6
7
# File 'lib/rubiks/measure.rb', line 4

def column(new_name=nil, options={})
  @column = new_name.to_s if new_name.present?
  @column ||= @options[:column] || name
end

#format_string(new_value = nil, options = {}) ⇒ Object



14
15
16
17
# File 'lib/rubiks/measure.rb', line 14

def format_string(new_value=nil, options={})
  @format_string = new_value.to_s if new_value.present?
  @format_string ||= @options[:format_string]
end

#to_xml(builder = nil) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/rubiks/measure.rb', line 19

def to_xml(builder = nil)
  builder = builder || new_builder

  xml_attrs = {:name => caption, :column => column, :aggregator => aggregator}
  xml_attrs[:formatString] = format_string if format_string.present?
  builder.measure(xml_attrs)
end