Skip to content

Instantly share code, notes, and snippets.

@lukedemi
Created February 2, 2017 17:47
Show Gist options
  • Save lukedemi/ec51c0fdeddb09cdbfe60b94891c680a to your computer and use it in GitHub Desktop.
Save lukedemi/ec51c0fdeddb09cdbfe60b94891c680a to your computer and use it in GitHub Desktop.
class GeoEngineer::Resource
validate -> { validate_has_tag(:Name) if support_tags? }
validate -> { validate_has_tag(:ProjectName) if self.project? && support_tags? }
validate :validate_project_name_correct
def validate_project_name_correct
bad_name = support_tags? && self.project && tags['ProjectName'] != self.project.full_name
"ProjectName tag should equal \"#{project.full_name}\" for resource \"#{type}.#{id}\"" if bad_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment