Skip to content

Commit

Permalink
fix Lint/Void
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed Jan 2, 2020
1 parent a18a55e commit 6a7703c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,6 @@ Lint/UselessAssignment:
- 'spec/features/events/organizer/event_organizer_dashboard_request_spec.rb'
- 'spec/jobs/survey_sender_spec.rb'

# Offense count: 1
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'app/models/concerns/presence_tracking_boolean.rb'

# Offense count: 45
Metrics/AbcSize:
Max: 249
Expand Down
39 changes: 19 additions & 20 deletions app/models/concerns/presence_tracking_boolean.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
module PresenceTrackingBoolean
extend ActiveSupport::Concern

<<-EOT
Add a setter and getter for a non-database-backed field representing
whether some other field is present. Assigning something falsy
to the setter will unset the tracked value.
EXAMPLE:
Rsvp.add_presence_tracking_boolean(:needs_childcare, :childcare_info)
rsvp = Rsvp.first
rsvp.childcare_info # 'Some String'
rsvp.needs_childcare? # true
# Rails forms will assign '0' or '1' (instead of `true` or `false`)
# to a non-database-backed checkbox field, usually
rsvp.assign_attributes(needs_childcare: '0')
rsvp.needs_childcare? # false
rsvp.childcare_info # nil
EOT
# Add a setter and getter for a non-database-backed field representing
# whether some other field is present. Assigning something falsy
# to the setter will unset the tracked value.
#
#
# ```
# Rsvp.add_presence_tracking_boolean(:needs_childcare, :childcare_info)
#
# rsvp = Rsvp.first
# rsvp.childcare_info # 'Some String'
# rsvp.needs_childcare? # true
#
# # Rails forms will assign '0' or '1' (instead of `true` or `false`)
# # to a non-database-backed checkbox field, usually
#
# rsvp.assign_attributes(needs_childcare: '0')
# rsvp.needs_childcare? # false
# rsvp.childcare_info # nil
# ```

included do
def self.add_presence_tracking_boolean(boolean_attribute, tracked_attribute)
Expand Down

0 comments on commit 6a7703c

Please sign in to comment.