Class: Clickwrap::EventStatement
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Clickwrap::EventStatement
- Defined in:
- lib/clickwrap/models/event_statement.rb
Overview
One act inside one event: the assertion in the server-generated offer and what the submitted answer said about it.
assertion_text is the resolved sentence, not an I18n key. Storing the key
would be a false economy — its meaning can change in a later deploy, and
then the receipt no longer says what assertion the application recorded.
Instance Method Summary collapse
- #canonical_fragment ⇒ Object
- #expired?(at = Clickwrap.now) ⇒ Boolean
-
#offered_and_not_taken? ⇒ Boolean
An optional control left unselected creates no grant.
- #to_s ⇒ Object
Instance Method Details
#canonical_fragment ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/clickwrap/models/event_statement.rb', line 42 def canonical_fragment { "statement" => statement_key, "kind" => kind, "action" => action, "assertion" => assertion_text, "locale" => assertion_locale, "label" => label_text, "link_labels" => link_labels.presence, "choices" => choices.presence, "required" => required?, "optional" => optional?, "answered" => answered?, "answer" => answer.presence, "purpose" => purpose_key, "withdrawal_path" => withdrawal_path, "valid_from" => Receipt.format_time(valid_from), "expires_at" => Receipt.format_time(expires_at), "one_time" => one_time? || nil, "requires" => Array(requires).presence, "subject_fingerprint" => subject_fingerprint }.compact end |
#expired?(at = Clickwrap.now) ⇒ Boolean
34 |
# File 'lib/clickwrap/models/event_statement.rb', line 34 def expired?(at = Clickwrap.now) = expires_at.present? && expires_at <= at |
#offered_and_not_taken? ⇒ Boolean
An optional control left unselected creates no grant. The receipt can show that the option was offered and not taken, but it does not call silence an affirmative refusal — those are different facts and only one of them actually happened.
40 |
# File 'lib/clickwrap/models/event_statement.rb', line 40 def offered_and_not_taken? = optional? && !answered? |
#to_s ⇒ Object
66 |
# File 'lib/clickwrap/models/event_statement.rb', line 66 def to_s = "#{kind} #{statement_key} (#{action})" |