Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/upmin/active_record/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def enum_attributes
end
end

def associations
return @associations if defined?(@associations)
def default_associations
return @default_associations if defined?(@default_associations)

all = []
ignored = []
Expand All @@ -59,7 +59,7 @@ def associations
end
end

return @associations = (all - ignored).uniq
return @default_associations = (all - ignored).uniq
end

end
Expand Down
17 changes: 17 additions & 0 deletions lib/upmin/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,18 @@ def Model.items_per_page(items = Upmin.configuration.items_per_page)
return @items_per_page ||= items
end

# Sets the associations to the provided associations if any are any
# provided. If no associations are provided then the associations are set to
# the default associations of the model class.
def Model.associations(*associations)
if associations.any?
@associations = associations.map{|a| a.to_sym}
end
@associations ||= default_associations

return @associations
end


###########################################################
### Methods that need to be to be overridden. If the
Expand All @@ -304,6 +316,11 @@ def Model.default_attributes
return default_attributes
end

def Model.default_associations
new
return default_associations
end

def Model.attribute_type(attribute)
new
return attribute_type(attribute)
Expand Down