Skip to content

Instantly share code, notes, and snippets.

@kirkconnell
Created September 30, 2011 23:17
Show Gist options
  • Select an option

  • Save kirkconnell/1255287 to your computer and use it in GitHub Desktop.

Select an option

Save kirkconnell/1255287 to your computer and use it in GitHub Desktop.
class LocationData::Profiles < ActiveResource::Base
self.schema = Front::PROFILE_SCHEMA
def method_missing(name, *args, &block)
super(name, *args, &block)
rescue NoMethodError, NameError => e
if name.to_s =~ /^(?:county|state|provincial)_profiles$/
[]
else
raise e
end
end
def state_profiles
super.select{|p| p.site_name != 'ps'}
end
def local_profiles
county_profiles.select{|p| p.site_name != 'ps'}
end
def page_two_profiles
(county_profiles + attributes[:state_profiles]).select{|p| p.site_name == 'ps' && p.confirmed?}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment