spec/fixtures/mappings/user_map.rb in spigot-0.1.0 vs spec/fixtures/mappings/user_map.rb in spigot-0.2.0
- old
+ new
@@ -1,59 +1,103 @@
module Spigot
module Mapping
-
class User
+
def self.basic
- {'user' => base}
+ template do
+ full_name :name
+ login :username
+ end
end
- def self.symbolized
- {user: {full_name: 'name', login: 'username'}}
+ 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
- {'user' => base.merge('login' => {'email' => 'contact', 'user_name' => 'username'})}
+ template do
+ full_name :name
+ login do
+ email :contact
+ user_name :username
+ end
+ end
end
def self.nested_twice
- {'user' => base.merge('login' => {
- 'contact' => {'work_email' => 'email', 'user_name' => 'username'}
- })}
+ template do
+ full_name :name
+ login do
+ last_seen_ip :ip
+ contact do
+ email :contact
+ user_name :username
+ end
+ end
+ end
end
- def self.array
- {'user' => base}
- end
-
def self.nested_array
- {'user' => {'account' => 'name', 'count' => 'user_count', 'users' => base}}
+ template do
+ account :name
+ count :user_count
+ users do
+ full_name :name
+ login :username
+ end
+ end
end
- def self.nested_account_members
- {'activeuser' => {'account_name' => 'name', 'url' => 'url', 'members' => {'login' => 'email', 'full_name' => 'name'}}}
- end
-
def self.with_options
- {'user' => base.merge('spigot' => options)}
+ template do
+ full_name :name
+ login :username
+ options do
+ primary_key :username
+ foreign_key :login
+ end
+ end
end
def self.with_conditions
- {'user' => base.merge('spigot' => options.merge(conditions))}
+ template do
+ full_name :name
+ login :username
+ options do
+ primary_key :username
+ foreign_key :login
+ end
+ end
end
private
- def self.base
- {'full_name' => 'name', 'login' => 'username'}
+ def self.template(&block)
+ Spigot.define do
+ service :github do
+ resource :user do
+ self.instance_eval(&block)
+ end
+ end
+ end
end
- def self.options
- {'primary_key' => 'username', 'foreign_key' => 'login'}
- end
-
- def self.conditions
- {'conditions' => 'username, name'}
- end
end
-
end
end