Sha256: 62c5f27a0d9c116eb2427901e6e48ca0bb87bd370113450ce3e70a85237c5e0f

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

module J7W1
  class Configuration
    module IOSEndpoint
      def sandbox?
        @sandbox
      end

      def arn
        self[:arn]
      end

      def confirm_sandbox
        @sandbox = (arn =~ /:app\/APNS_SANDBOX\//)
      end
    end

    module AndroidEndpoint
      def arn
        self[:arn]
      end
    end 

    module Account
      [:access_key_id, :secret_access_key, :region].each do |attr|
        define_method(attr){self[attr]}
      end
    end

    def initialize(configuration_values)
      @values = configuration_values
      if ios_endpoint
        ios_endpoint.extend(IOSEndpoint)
        ios_endpoint.confirm_sandbox
      end
      android_endpoint.extend(AndroidEndpoint) if android_endpoint
      account.extend(Account)
    end

    def account
      @values[:account]
    end

    def ios_endpoint
      @values[:app_endpoint][:ios]
    end

    def android_endpoint
      #TODO configの対応
      @values[:app_endpoint][:android]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
j7w1-0.0.11 lib/j7w1/configuration.rb