Module: Hisui::Model

Defined in:
lib/hisui/model.rb

Instance Method Summary collapse

Instance Method Details

#dimensions(*field) ⇒ ListParameter

Adds dimensions to the class for retrieval from GA

Parameters:

  • fields (Symbol)

    the names of the fields to retrieve

Returns:

  • (ListParameter)

    the set of all dimensions



17
18
19
20
21
# File 'lib/hisui/model.rb', line 17

def dimensions(*field)
  @dimensions ||= Set.new([])
  field.try(:each) { |f| @dimensions << { name: Hisui.to_ga_string(f) } }
  @dimensions
end

#metrics(*field) ⇒ ListParameter

Adds metrics to the class for retrieval from GA

Parameters:

  • fields (Symbol)

    the names of the fields to retrieve

Returns:

  • (ListParameter)

    the set of all metrics



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

def metrics(*field)
  @metrics ||= Set.new([])
  field.try(:each) { |f| @metrics << { expression: Hisui.to_ga_string(f) } }
  @metrics
end

#order_bys(field = nil) ⇒ Object

Parameters:

  • field (Hash) (defaults to: nil)

    options:

    • field_name

    • order_type

    • sort_order



31
32
33
34
35
# File 'lib/hisui/model.rb', line 31

def order_bys(field = nil)
  @order_bys ||= Set.new([])
  @order_bys << field if field
  @order_bys
end

#results(profile:, **options) ⇒ Object



37
38
39
# File 'lib/hisui/model.rb', line 37

def results(profile:, **options)
  Hisui::Request.new(profile: profile, model: self, **options).fetch_data
end