Class: Warrant::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/warrant/models/subject.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_idObject (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_typeObject (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

#relationObject (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