diff --git a/lib/upmin/active_record/model.rb b/lib/upmin/active_record/model.rb index e3e9688..626115f 100644 --- a/lib/upmin/active_record/model.rb +++ b/lib/upmin/active_record/model.rb @@ -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 = [] @@ -59,7 +59,7 @@ def associations end end - return @associations = (all - ignored).uniq + return @default_associations = (all - ignored).uniq end end diff --git a/lib/upmin/model.rb b/lib/upmin/model.rb index d38ba33..927a347 100644 --- a/lib/upmin/model.rb +++ b/lib/upmin/model.rb @@ -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 @@ -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)