Class: Warrant::Subject
- Inherits:
-
Object
- Object
- Warrant::Subject
- Defined in:
- lib/warrant/models/subject.rb
Instance Attribute Summary collapse
-
#object_id ⇒ Object
readonly
Returns the value of attribute object_id.
-
#object_type ⇒ Object
readonly
Returns the value of attribute object_type.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object_type, object_id, relation = nil) ⇒ Subject
constructor
A new instance of Subject.
Constructor Details
#initialize(object_type, object_id, relation = nil) ⇒ Subject
Returns a new instance of Subject.
7 8 9 10 11 |
# File 'lib/warrant/models/subject.rb', line 7 def initialize(object_type, object_id, relation = nil) @object_type = object_type @object_id = object_id @relation = relation end |
Instance Attribute Details
#object_id ⇒ Object (readonly)
Returns the value of attribute object_id.
5 6 7 |
# File 'lib/warrant/models/subject.rb', line 5 def object_id @object_id end |
#object_type ⇒ Object (readonly)
Returns the value of attribute object_type.
5 6 7 |
# File 'lib/warrant/models/subject.rb', line 5 def object_type @object_type end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
5 6 7 |
# File 'lib/warrant/models/subject.rb', line 5 def relation @relation end |
Class Method Details
.new_from_hash(attributes) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/warrant/models/subject.rb', line 13 def self.new_from_hash(attributes) object_type = attributes.fetch(:object_type) object_id = attributes.fetch(:object_id) relation = attributes.fetch(:relation, nil) self.new(object_type, object_id, relation) end |