| Total Complexity | 4 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | require 'multi_json' |
||
| 7 | class Client |
||
| 8 | attr_accessor :api |
||
| 9 | attr_accessor :logger |
||
| 10 | attr_accessor :groups |
||
| 11 | attr_accessor :groups_cache |
||
| 12 | attr_accessor :persons |
||
| 13 | attr_accessor :posts |
||
| 14 | |||
| 15 | def initialize(rc_sdk) |
||
| 16 | @api = rc_sdk |
||
| 17 | @logger = @api.config.logger |
||
| 18 | |||
| 19 | @groups_cache = GlipSdk::REST::Cache::Groups.new |
||
| 20 | |||
| 21 | @groups = GlipSdk::REST::Groups.new @api |
||
| 22 | @persons = GlipSdk::REST::Persons.new @api |
||
| 23 | @posts = GlipSdk::REST::Posts.new @api |
||
| 24 | end |
||
| 25 | |||
| 26 | def load_groups_cache(filepath = nil) |
||
| 27 | if !filepath.nil? && File.exist?(filepath) |
||
| 28 | groups_json = IO.read filepath |
||
| 29 | all_groups = MultiJson.decode groups_json |
||
| 30 | @groups_cache.load_groups all_groups |
||
| 31 | else |
||
| 32 | @groups_cache.load_groups @groups.all_groups |
||
| 33 | end |
||
| 34 | |||
| 35 | @posts.groups_cache = @groups_cache |
||
| 36 | end |
||
| 37 | end |
||
| 38 | end |
||
| 40 |