Sha256: 710ffb58a4df69e43c64983b20eb5bf1ceb5b951cc0193be9dc395e18b9a4358

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 Bytes

Contents

require 'spigot'

Spigot.configure do |config|
  config.translations = {
    'user' => {
      'full_name' => 'name',
      'login' => 'username'
    }
  }
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

user = User.build
puts user.name
puts user.inspect

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spigot-0.1.0 examples/model.rb
spigot-0.0.1 examples/model.rb