Sha256: 9ed8c1c78d7fe7b6343af27fca6c30f621881992959969d6913ce0cc51460992

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

module Spigot
  module Mapping
    class User

      def self.basic
        template do
          full_name :name
          login     :username
        end
      end

      def self.interpolated
        template do
          full_name :name
          login :username do |value|
            "@#{value}"
          end
        end
      end

      def self.nested_interpolation
        template do
          full_name :name
          login do
            email      :contact
            user_name  :username do |value|
              "@#{value}"
            end
          end
        end
      end

      def self.nested
        template do
          full_name :name
          login do
            email     :contact
            user_name :username
          end
        end
      end

      def self.nested_twice
        template do
          full_name :name
          login do
            last_seen_ip :ip
            contact do
              email     :contact
              user_name :username
            end
          end
        end
      end

      def self.nested_array
        template do
          account :name
          count   :user_count
          users do
            full_name :name
            login :username
          end
        end
      end

      def self.with_options
        template do
          full_name :name
          login     :username
          options do
            primary_key :username
            foreign_key :login
          end
        end
      end

      def self.with_conditions
        template do
          full_name :name
          login     :username
          options do
            primary_key :username
            foreign_key :login
          end
        end
      end

      private

      def self.template(&block)
        Spigot.define do
          service :github do
            resource :user do
              self.instance_eval(&block)
            end
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spigot-0.2.0 spec/fixtures/mappings/user_map.rb