Module: Devise::Models::DateRestrictable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/devise_date_restrictable/active_record.rb
Class Method Summary collapse
Instance Method Summary collapse
- #access_locked? ⇒ Boolean
- #active_for_authentication? ⇒ Boolean
- #date_restricted? ⇒ Boolean
- #inactive_message ⇒ Object
Class Method Details
.required_fields(klass) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/devise_date_restrictable/active_record.rb', line 16 def self.required_fields(klass) attributes = [] attributes << :valid_from attributes << :valid_until attributes end |
Instance Method Details
#access_locked? ⇒ Boolean
23 24 25 |
# File 'lib/devise_date_restrictable/active_record.rb', line 23 def access_locked? date_restricted? end |
#active_for_authentication? ⇒ Boolean
27 28 29 |
# File 'lib/devise_date_restrictable/active_record.rb', line 27 def active_for_authentication? super && !date_restricted? end |
#date_restricted? ⇒ Boolean
6 7 8 9 10 11 12 13 14 |
# File 'lib/devise_date_restrictable/active_record.rb', line 6 def date_restricted? now = Date.today puts now.inspect puts valid_from.nil?.inspect puts valid_until.nil?.inspect !((valid_from.nil? or now >= valid_from) and (valid_until.nil? or now <= valid_until)) end |
#inactive_message ⇒ Object
31 32 33 |
# File 'lib/devise_date_restrictable/active_record.rb', line 31 def date_restricted? ? :account_date_restricted : super end |