Module: Effective::Resources::Associations
- Included in:
- Effective::Resource
- Defined in:
- app/models/effective/resources/associations.rb
Instance Method Summary collapse
- #belong_tos ⇒ Object
- #has_manys ⇒ Object
- #has_ones ⇒ Object
- #nested_resources ⇒ Object
- #scopes ⇒ Object
Instance Method Details
#belong_tos ⇒ Object
5 6 7 8 |
# File 'app/models/effective/resources/associations.rb', line 5 def belong_tos return [] unless klass.respond_to?(:reflect_on_all_associations) @belong_tos ||= klass.reflect_on_all_associations(:belongs_to) end |
#has_manys ⇒ Object
15 16 17 18 |
# File 'app/models/effective/resources/associations.rb', line 15 def has_manys return [] unless klass.respond_to?(:reflect_on_all_associations) @has_manys ||= klass.reflect_on_all_associations(:has_many).reject { |association| association.[:autosave] } end |
#has_ones ⇒ Object
10 11 12 13 |
# File 'app/models/effective/resources/associations.rb', line 10 def has_ones return [] unless klass.respond_to?(:reflect_on_all_associations) @has_ones ||= klass.reflect_on_all_associations(:has_one) end |
#nested_resources ⇒ Object
20 21 22 23 |
# File 'app/models/effective/resources/associations.rb', line 20 def nested_resources return [] unless klass.respond_to?(:reflect_on_all_associations) @nested_resources ||= klass.reflect_on_all_associations(:has_many).select { |association| association.[:autosave] } end |
#scopes ⇒ Object
25 26 |
# File 'app/models/effective/resources/associations.rb', line 25 def scopes end |