Sha256: 01f19f6835fdf5bb05a66835cd10d5404f81c49bb432637b405f6c63426ea36b

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 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
        end
        klass.new link
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fb_graph2-0.1.0 lib/fb_graph2/app_link_host.rb
fb_graph2-0.0.11 lib/fb_graph2/app_link_host.rb
fb_graph2-0.0.10 lib/fb_graph2/app_link_host.rb
fb_graph2-0.0.9 lib/fb_graph2/app_link_host.rb
fb_graph2-0.0.8 lib/fb_graph2/app_link_host.rb