Class: IAmICan::ThatAllow
- Inherits:
-
Object
- Object
- IAmICan::ThatAllow
- Defined in:
- lib/i_am_i_can/resource.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
Returns the value of attribute records.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
-
#initialize(records, subject) ⇒ ThatAllow
constructor
A new instance of ThatAllow.
- #to(pred) ⇒ Object
Constructor Details
#initialize(records, subject) ⇒ ThatAllow
Returns a new instance of ThatAllow.
17 18 19 20 |
# File 'lib/i_am_i_can/resource.rb', line 17 def initialize(records, subject) self.records = records self.subject = subject end |
Instance Attribute Details
#records ⇒ Object
Returns the value of attribute records.
15 16 17 |
# File 'lib/i_am_i_can/resource.rb', line 15 def records @records end |
#subject ⇒ Object
Returns the value of attribute subject.
15 16 17 |
# File 'lib/i_am_i_can/resource.rb', line 15 def subject @subject end |
Instance Method Details
#to(pred) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/i_am_i_can/resource.rb', line 22 def to(pred) roles = Configs.take.subject_model._roles = Configs.take.role_model. allowed_ids = subject.send(roles).send().where(pred: pred, obj_type: records.name).pluck(:obj_id) records.where(id: allowed_ids) end |