Skip to content

Instantly share code, notes, and snippets.

@kris
Last active August 29, 2015 14:08
Show Gist options
  • Save kris/9bc061761093acb91df9 to your computer and use it in GitHub Desktop.
Save kris/9bc061761093acb91df9 to your computer and use it in GitHub Desktop.
class Widget
# BusinessSearch widget
#
# Attributes:
#
# cache - Total seconds to cache the data from this widget
# type_list - Types of businesses to search
#
# Methods:
#
# #business_types - Get list of Business types to search
#
class BusinessSearch < Base
attr_accessor :type_list
validates :type_list, presence: true
# Get a list of business class constants
#
# @return [Array]
def business_types
safely(Array.new) do
Array(type_list).collect do |type|
type.to_s.classify.constantize
end
end
end
# This doesn't have dynamic content to cache
#
# @return [Integer]
def cache
0
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment