Module: RestPack::Resource::Includable
- Defined in:
- lib/restpack-resource/resource/includable.rb
Instance Method Summary collapse
- #resource_can_include(*associations) ⇒ Object
- #resource_includable_associations ⇒ Object
- #resource_includable_associations=(associations) ⇒ Object
- #resource_validate_includes!(includes) ⇒ Object
Instance Method Details
#resource_can_include(*associations) ⇒ Object
12 13 14 |
# File 'lib/restpack-resource/resource/includable.rb', line 12 def resource_can_include(*associations) self.resource_includable_associations += associations end |
#resource_includable_associations ⇒ Object
6 7 8 |
# File 'lib/restpack-resource/resource/includable.rb', line 6 def resource_includable_associations @resource_includable_associations || [] end |
#resource_includable_associations=(associations) ⇒ Object
9 10 11 |
# File 'lib/restpack-resource/resource/includable.rb', line 9 def resource_includable_associations=(associations) @resource_includable_associations = associations.uniq end |
#resource_validate_includes!(includes) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/restpack-resource/resource/includable.rb', line 15 def resource_validate_includes!(includes) includes.each do |include| unless self.resource_includable_associations.include?(include.to_sym) raise InvalidInclude, "#{self.name}.#{include} is not an includable relation" end end end |