Class: Blazer::Query
- Defined in:
- app/models/blazer/query.rb
Instance Method Summary collapse
- #cohort_analysis? ⇒ Boolean
- #editable?(user) ⇒ Boolean
- #friendly_name ⇒ Object
- #to_param ⇒ Object
- #variables ⇒ Object
- #viewable?(user) ⇒ Boolean
Instance Method Details
#cohort_analysis? ⇒ Boolean
43 44 45 |
# File 'app/models/blazer/query.rb', line 43 def cohort_analysis? /\/\*\s*cohort analysis\s*\*\//i.match?(statement) end |
#editable?(user) ⇒ Boolean
30 31 32 33 34 35 |
# File 'app/models/blazer/query.rb', line 30 def editable?(user) editable = !persisted? || (name.present? && name.first != "*" && name.first != "#") || user == try(:creator) editable &&= viewable?(user) editable &&= Blazer.query_editable.call(self, user) if Blazer.query_editable editable end |
#friendly_name ⇒ Object
18 19 20 |
# File 'app/models/blazer/query.rb', line 18 def friendly_name name.to_s.sub(/\A[#\*]/, "").gsub(/\[.+\]/, "").strip end |
#to_param ⇒ Object
14 15 16 |
# File 'app/models/blazer/query.rb', line 14 def to_param [id, name].compact.join("-").gsub("'", "").parameterize end |
#variables ⇒ Object
37 38 39 40 41 |
# File 'app/models/blazer/query.rb', line 37 def variables variables = Blazer.extract_vars(statement) variables += ["cohort_period"] if cohort_analysis? variables end |
#viewable?(user) ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'app/models/blazer/query.rb', line 22 def viewable?(user) if Blazer.query_viewable Blazer.query_viewable.call(self, user) else true end end |