balanced 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/examples/examples.rb CHANGED
@@ -30,23 +30,23 @@ puts "create our marketplace"
30
30
  begin
31
31
  marketplace = Balanced::Marketplace.new.save
32
32
  rescue Balanced::Conflict => ex
33
- marketplace = Balanced::Marketplace.my_marketplace
33
+ marketplace = Balanced::Marketplace.mine
34
34
  end
35
35
 
36
36
  raise "Merchant.me should not be nil" if Balanced::Merchant.me.nil?
37
37
  puts "what's my merchant?, easy: Merchant.me: ", Balanced::Merchant.me
38
38
 
39
39
  # what's my marketplace?
40
- raise "Marketplace.my_marketplace should not be nil" if Balanced::Marketplace.my_marketplace.nil?
41
- puts "what's my marketplace?, easy: Marketplace.my_marketplace: ", Balanced::Marketplace.my_marketplace
40
+ raise "Marketplace.mine should not be nil" if Balanced::Marketplace.mine.nil?
41
+ puts "what's my marketplace?, easy: Marketplace.mine: ", Balanced::Marketplace.mine
42
42
 
43
43
  puts "My marketplace's name is: #{marketplace.name}"
44
44
  random_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
45
45
  puts "Changing it to #{random_name}"
46
46
  marketplace.name = random_name
47
47
  marketplace.save
48
- puts "My marketplace name is now: #{Balanced::Marketplace.my_marketplace.name}"
49
- raise "Marketplace name is NOT #{random_name}!" if Balanced::Marketplace.my_marketplace.name != random_name
48
+ puts "My marketplace name is now: #{Balanced::Marketplace.mine.name}"
49
+ raise "Marketplace name is NOT #{random_name}!" if Balanced::Marketplace.mine.name != random_name
50
50
 
51
51
  puts "cool! let's create a new card."
52
52
  card = Balanced::Card.new(
@@ -6,30 +6,35 @@ module Balanced
6
6
 
7
7
  @@marketplace_uri = nil
8
8
 
9
- # Returns an instance representing the marketplace associated with
10
- # the current API key.
11
- #
12
- # @return [Marketplace]
13
- def self.my_marketplace
14
- marketplace = Balanced::Merchant.me.marketplace
15
- @@marketplace_uri = marketplace.uri if marketplace
16
- marketplace
17
- end
18
-
19
- # @return [String, nil] the marketplace's URI
20
- def self.marketplace_uri
21
- if !@@marketplace_uri and Balanced.is_configured_with_api_key?
22
- begin
23
- self.my_marketplace
24
- rescue Balanced::Error
25
- # do nothing..
9
+ class << self
10
+
11
+ # Returns an instance representing the marketplace associated with
12
+ # the current API key.
13
+ #
14
+ # @return [Marketplace]
15
+ def my_marketplace
16
+ marketplace = Balanced::Merchant.me.marketplace
17
+ @@marketplace_uri = marketplace.uri if marketplace
18
+ marketplace
19
+ end
20
+ alias mine my_marketplace
21
+
22
+ # @return [String, nil] the marketplace's URI
23
+ def marketplace_uri
24
+ if !@@marketplace_uri and Balanced.is_configured_with_api_key?
25
+ begin
26
+ mine
27
+ rescue Balanced::Error
28
+ # do nothing..
29
+ end
26
30
  end
31
+ @@marketplace_uri
32
+ end
33
+
34
+ def marketplace_exists?
35
+ !!marketplace_uri
27
36
  end
28
- @@marketplace_uri
29
- end
30
37
 
31
- def self.marketplace_exists?
32
- !!marketplace_uri
33
38
  end
34
39
 
35
40
  # @return [Marketplace]
@@ -46,6 +51,7 @@ module Balanced
46
51
  def my_marketplace
47
52
  self.class.my_marketplace
48
53
  end
54
+ alias mine my_marketplace
49
55
 
50
56
  # Create an Account associated with this Marketplace. This account
51
57
  # will have no roles associated with it.
@@ -1,3 +1,3 @@
1
1
  module Balanced
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balanced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: