Module: Legato::Model

Defined in:
lib/legato/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



3
4
5
# File 'lib/legato/model.rb', line 3

def self.extended(base)
  ProfileMethods.add_profile_method(base)
end

Instance Method Details

#dimensions(*fields) ⇒ Object



12
13
14
15
# File 'lib/legato/model.rb', line 12

def dimensions(*fields)
  @dimensions ||= ListParameter.new(:dimensions)
  @dimensions << fields
end

#filter(name, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/legato/model.rb', line 21

def filter(name, &block)
  filters[name] = block

  (class << self; self; end).instance_eval do
    define_method(name) {|*args| Query.new(self).apply_filter(*args, &block)}
  end
end

#filtersObject



17
18
19
# File 'lib/legato/model.rb', line 17

def filters
  @filters ||= {}
end

#instance_klassObject



45
46
47
# File 'lib/legato/model.rb', line 45

def instance_klass
  @instance_klass || OpenStruct
end

#metrics(*fields) ⇒ Object



7
8
9
10
# File 'lib/legato/model.rb', line 7

def metrics(*fields)
  @metrics ||= ListParameter.new(:metrics)
  @metrics << fields
end

#results(profile, options = {}) ⇒ Object



49
50
51
# File 'lib/legato/model.rb', line 49

def results(profile, options = {})
  Query.new(self).results(profile, options)
end

#segment(name, &block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/legato/model.rb', line 33

def segment(name, &block)
  segments[name] = block

  (class << self; self; end).instance_eval do
    define_method(name) {|*args| Query.new(self).apply_segment_filter(*args, &block)}
  end
end

#segmentsObject



29
30
31
# File 'lib/legato/model.rb', line 29

def segments
  @segments ||= {}
end

#set_instance_klass(klass) ⇒ Object



41
42
43
# File 'lib/legato/model.rb', line 41

def set_instance_klass(klass)
  @instance_klass = klass
end