Module: GitHubRecordsArchiver::DataHelper

Included in:
Comment, Issue, Organization, Repository, Team, User, Wiki
Defined in:
lib/github_records_archiver/data_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/github_records_archiver/data_helper.rb', line 5

def method_missing(method_sym, *arguments, &block)
  return data[method_sym] if data_key?(method_sym)
  if method_sym.to_s.end_with? '?'
    !send(non_predicate_method(method_sym)).to_s.empty?
  else
    super
  end
end

Instance Attribute Details

#dataObject



31
32
33
# File 'lib/github_records_archiver/data_helper.rb', line 31

def data
  raise 'Not implemented'
end

Instance Method Details

#respond_to_missing?(method_sym, include_private = false) ⇒ Boolean

Returns:



14
15
16
17
18
19
20
# File 'lib/github_records_archiver/data_helper.rb', line 14

def respond_to_missing?(method_sym, include_private = false)
  if data_key? non_predicate_method(method_sym)
    true
  else
    super
  end
end

#to_hObject Also known as: as_json



22
23
24
# File 'lib/github_records_archiver/data_helper.rb', line 22

def to_h
  data.to_h
end

#to_jsonObject



27
28
29
# File 'lib/github_records_archiver/data_helper.rb', line 27

def to_json
  as_json.to_json
end