Sha256: b0f6d143bcd7c9ed5a04666c72027d346eccddbf8cc3de9027a311ec9f5c64c6
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'spigot' Spigot.define do service :twitter do resource :user do id :twitter_id name :name username :username end end end Spigot.define do service :github do resource :user do id :github_id full_name :name login :username contact do address :address telephone do work :work_phone home :home_phone end url :homepage do |value| "https://github.com/#{value}" end end end resource :pull_request do id :id title :title body :body end end end class User include Spigot::Base attr_reader :name, :username def initialize(params={}) params.each_pair do |k, v| instance_variable_set("@#{k}".to_sym, v) end end def self.api_data { full_name: 'matthew', login: 'mwerner' } end def self.build new_by_api(:github, api_data) end end puts "Map Built:" puts Spigot.config.map.to_hash user = User.build puts "\nUser Parsed:" puts user.name puts user.inspect
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spigot-0.2.2 | examples/model.rb |
spigot-0.2.1 | examples/model.rb |
spigot-0.2.0 | examples/model.rb |