Class: Blazer::Query

Inherits:
Record
  • Object
show all
Defined in:
app/models/blazer/query.rb

Instance Method Summary collapse

Instance Method Details

#cohort_analysis?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'app/models/blazer/query.rb', line 33

def cohort_analysis?
  # don't require data_source to be loaded
  Statement.new(statement).cohort_analysis?
end

#editable?(user) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/blazer/query.rb', line 22

def editable?(user)
  !persisted? || (name.present? && name.first != "*" && name.first != "#") || user == try(:creator)
end

#friendly_nameObject



18
19
20
# File 'app/models/blazer/query.rb', line 18

def friendly_name
  name.to_s.sub(/\A[#\*]/, "").gsub(/\[.+\]/, "").strip
end

#statement_objectObject



38
39
40
# File 'app/models/blazer/query.rb', line 38

def statement_object
  Statement.new(statement, data_source)
end

#to_paramObject



14
15
16
# File 'app/models/blazer/query.rb', line 14

def to_param
  [id, name].compact.join("-").gsub("'", "").parameterize
end

#variablesObject



26
27
28
29
30
31
# File 'app/models/blazer/query.rb', line 26

def variables
  # don't require data_source to be loaded
  variables = Statement.new(statement).variables
  variables += ["cohort_period"] if cohort_analysis?
  variables
end