Sha256: d575547fc6d50ed2247fbcefaa7a9a74b7dd7bd97507a0bc198600ccb114d59d

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module FbGraph
  class Page
    module Categories
      module LocalBusiness
        attr_accessor :attire, :culinary_team, :general_manager, :hours, :parking, :payment_options, :phone, :price_range, :public_transit, :restaurant_services, :restaurant_specialties

        def self.included(klass)
          klass.alias_method_chain :initialize, :category_specific_attributes
        end

        def initialize_with_category_specific_attributes(identifier, attributes = {})
          initialize_without_category_specific_attributes identifier, attributes
          [:attire, :culinary_team, :general_manager, :phone, :price_range, :public_transit].each do |key|
            self.send :"#{key}=", attributes[key]
          end
          [:parking, :payment_options, :restaurant_services, :restaurant_specialties].each do |key|
            self.send :"#{key}=", []
            if attributes[key]
              self.send :"#{key}=", attributes[key].keys.collect(&:to_sym)
            end
          end
          @hours = {}
          if attributes[:hours]
            utc_beginning_of_day = Time.now.utc.beginning_of_day
            attributes[:hours].each do |key, value|
              date, index, mode = key.split('_')
              index = index.to_i - 1
              date, mode = date.to_sym, mode.to_sym
              @hours[date] ||= []
              @hours[date][index] ||= {}
              @hours[date][index][mode] = value.since(utc_beginning_of_day)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb_graph-1.6.1 lib/fb_graph/page/categories/local_business.rb