Sha256: a2a1dafa631dbd42dd2b57af1a66b9bfacd89509e4cdbf421d177a5660ece50c

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

module FbGraph2
  class AppLinkHost < Node
    register_attributes(
      raw: [:name, :canonical_url],
      custom: [:ios, :iphone, :ipad, :android, :windows_phone, :web]
    )

    def initialize(id, attributes = {})
      super
      [:ios, :iphone, :ipad, :android, :windows_phone].each do |link_attr|
        if attributes.include? link_attr
          self.send :"#{link_attr}=", collect_links(attributes, link_attr)
        end
      end
    end

    private

    def collect_links(attributes, link_attr)
      Collection.new(attributes[link_attr]).collect do |link|
        klass = case link_attr
        when :ios, :iphone, :ipad
          Struct::AppLink::Native::IOS
        when :android
          Struct::AppLink::Native::Android
        when :windows_phone
          Struct::AppLink::Native::WindowsPhone
        else
          raise 'Unknown AppLink Type'
        end
        klass.new link
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fb_graph2-0.0.7 lib/fb_graph2/app_link_host.rb
fb_graph2-0.0.6 lib/fb_graph2/app_link_host.rb