dynarex-usersblog 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/dynarex-usersblog.rb +11 -7
  2. metadata +2 -2
@@ -19,8 +19,7 @@ class DynarexUsersBlog
19
19
 
20
20
  FileUtils.mkdir_p user_file_path
21
21
  @hc_blog = HashCache.new
22
- @user_blog = @hc_blog.read(user) { DynarexBlog.new user_file_path }
23
- @current_blog = @user_blog
22
+ switch_user user
24
23
  end
25
24
  }
26
25
 
@@ -50,9 +49,8 @@ class DynarexUsersBlog
50
49
  @master_blog.tag(tag_name)
51
50
  end
52
51
 
53
- def user(user_name)
54
- user_file_path = "%s/users/%s" % [@file_path, @current_user]
55
- @hc_blog.read(@current_user) { DynarexBlog.new user_file_path }
52
+ def user(username)
53
+ (@current_user == username ? @current_user : switch_user(username))
56
54
  end
57
55
 
58
56
  def entry(id)
@@ -63,11 +61,17 @@ class DynarexUsersBlog
63
61
  @master_blog.tags
64
62
  end
65
63
 
66
- def update(id=0, h={})
64
+ def update_user(user, id=0, h={})
65
+ switch_user user unless @current_user == user
67
66
  @user_blog.update(id, h)
68
67
  @master_blog.update(id, h)
69
68
  end
70
-
69
+
70
+ def switch_user(user)
71
+ user_file_path = "%s/users/%s" % [@file_path, user]
72
+ @user_blog = @hc_blog.read(user) { DynarexBlog.new user_file_path }
73
+ @current_blog = @user_blog
74
+ end
71
75
 
72
76
  end
73
77
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex-usersblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-08-29 00:00:00 +01:00
12
+ date: 2010-08-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency