Commit 81ee605 1 parent 0df73e9 commit 81ee605 Copy full SHA for 81ee605
File tree 3 files changed +43
-12
lines changed
3 files changed +43
-12
lines changed Original file line number Diff line number Diff line change 1
1
require "letter_avatar/version"
2
+ require "letter_avatar/configuration"
2
3
require "letter_avatar/avatar"
3
4
require "letter_avatar/avatar_helper"
4
5
5
6
module LetterAvatar
6
-
7
- mattr_accessor :cache_base_path
8
- @@cache_base_path = nil
9
-
10
- mattr_accessor :colors_palette
11
- @@colors_palette = :google
12
-
13
- mattr_accessor :weight
14
- @@weight = 300
15
-
16
- mattr_accessor :annotate_position
17
- @@annotate_position = '-0+5'
7
+ extend LetterAvatar ::Configuration
18
8
19
9
def self . setup ( &block )
20
10
yield ( self )
Original file line number Diff line number Diff line change 1
1
module LetterAvatar
2
2
module Colors
3
3
4
+ PALETTES = [ :google , :iwanthue ]
5
+
4
6
def self . for ( username )
5
7
public_send ( "with_#{ LetterAvatar . colors_palette } " , username ) rescue with_google ( username )
6
8
end
Original file line number Diff line number Diff line change
1
+ require "letter_avatar/colors"
2
+
3
+ module LetterAvatar
4
+ module Configuration
5
+
6
+ def cache_base_path
7
+ Thread . current [ :cache_base_path ]
8
+ end
9
+
10
+ def cache_base_path = ( v )
11
+ Thread . current [ :cache_base_path ] = v
12
+ end
13
+
14
+ def colors_palette
15
+ Thread . current [ :colors_palette ] ||= :google
16
+ end
17
+
18
+ def colors_palette = ( v )
19
+ Thread . current [ :colors_palette ] = v if v . in? ( Colors ::PALETTES )
20
+ end
21
+
22
+ def weight
23
+ Thread . current [ :weight ] ||= 300
24
+ end
25
+
26
+ def weight = ( v )
27
+ Thread . current [ :weight ] = v
28
+ end
29
+
30
+ def annotate_position
31
+ Thread . current [ :annotate_position ] ||= '-0+5'
32
+ end
33
+
34
+ def annotate_position = ( v )
35
+ Thread . current [ :annotate_position ] = v
36
+ end
37
+
38
+ end
39
+ end
You can’t perform that action at this time.
0 commit comments