Class: YaPPL::Rule
- Inherits:
-
Object
- Object
- YaPPL::Rule
- Defined in:
- lib/rule.rb
Instance Attribute Summary collapse
-
#excluded_purposes ⇒ Object
readonly
Returns the value of attribute excluded_purposes.
-
#excluded_utilizers ⇒ Object
readonly
Returns the value of attribute excluded_utilizers.
-
#expiration_date ⇒ Object
readonly
Returns the value of attribute expiration_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#permitted_purposes ⇒ Object
readonly
Returns the value of attribute permitted_purposes.
-
#permitted_utilizers ⇒ Object
readonly
Returns the value of attribute permitted_utilizers.
-
#transformations ⇒ Object
readonly
Returns the value of attribute transformations.
-
#valid_from ⇒ Object
readonly
Returns the value of attribute valid_from.
Instance Method Summary collapse
- #archive! ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(args = {}) ⇒ Rule
constructor
A new instance of Rule.
- #to_h ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Rule
Returns a new instance of Rule.
7 8 9 10 11 12 13 |
# File 'lib/rule.rb', line 7 def initialize(args = {}) args.each do |key, value| self.instance_variable_set("@#{key}".to_sym, value) end @valid_from = Time.now unless valid_from @expiration_date = default_time unless expiration_date end |
Instance Attribute Details
#excluded_purposes ⇒ Object (readonly)
Returns the value of attribute excluded_purposes.
4 5 6 |
# File 'lib/rule.rb', line 4 def excluded_purposes @excluded_purposes end |
#excluded_utilizers ⇒ Object (readonly)
Returns the value of attribute excluded_utilizers.
4 5 6 |
# File 'lib/rule.rb', line 4 def excluded_utilizers @excluded_utilizers end |
#expiration_date ⇒ Object (readonly)
Returns the value of attribute expiration_date.
4 5 6 |
# File 'lib/rule.rb', line 4 def expiration_date @expiration_date end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/rule.rb', line 3 def id @id end |
#permitted_purposes ⇒ Object (readonly)
Returns the value of attribute permitted_purposes.
4 5 6 |
# File 'lib/rule.rb', line 4 def permitted_purposes @permitted_purposes end |
#permitted_utilizers ⇒ Object (readonly)
Returns the value of attribute permitted_utilizers.
4 5 6 |
# File 'lib/rule.rb', line 4 def permitted_utilizers @permitted_utilizers end |
#transformations ⇒ Object (readonly)
Returns the value of attribute transformations.
4 5 6 |
# File 'lib/rule.rb', line 4 def transformations @transformations end |
#valid_from ⇒ Object (readonly)
Returns the value of attribute valid_from.
4 5 6 |
# File 'lib/rule.rb', line 4 def valid_from @valid_from end |
Instance Method Details
#archive! ⇒ Object
15 16 17 18 |
# File 'lib/rule.rb', line 15 def archive! @id = -1 @expiration_date = Time.now end |
#expired? ⇒ Boolean
20 21 22 |
# File 'lib/rule.rb', line 20 def expired? expiration_date != default_time && Time.now > expiration_date end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rule.rb', line 24 def to_h { purpose: { permitted: permitted_purposes, excluded: excluded_purposes }, utilizer: { permitted: permitted_utilizers, excluded: excluded_utilizers }, transformation: transformations, valid_from: valid_from.strftime('%FT%T.%LZ'), exp_date: expiration_date.strftime('%FT%T.%LZ') } end |