Class: Blackbaud::BlackbaudObject
- Inherits:
-
Object
- Object
- Blackbaud::BlackbaudObject
- Defined in:
- lib/blackbaud-client/api/blackbaud_object.rb
Direct Known Subclasses
AcademicYear, AttendanceCode, AttendanceRecord, BlackbaudClass, CodeTable, CodeTableEntry, Contact, Grade, MarkingColumn, Person, Relation, Session, StaticCodeTable, Term, TranslationTable, TranslationTableEntry
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #format_date(d) ⇒ Object
-
#initialize(options) ⇒ BlackbaudObject
constructor
A new instance of BlackbaudObject.
- #to_hash(keys = nil) ⇒ Object (also: #to_h)
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(options) ⇒ BlackbaudObject
Returns a new instance of BlackbaudObject.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/blackbaud-client/api/blackbaud_object.rb', line 6 def initialize() @client ||= .delete(:client) .fetch(:values).each do |k,v| send("#{k}=".intern, v) if respond_to?("#{k}=".intern) end rescue NoMethodError puts "NoMethodError: There is no method for one of the keys in your options: #{}" return nil end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/blackbaud-client/api/blackbaud_object.rb', line 4 def client @client end |
Instance Method Details
#format_date(d) ⇒ Object
17 18 19 |
# File 'lib/blackbaud-client/api/blackbaud_object.rb', line 17 def format_date(d) DateTime.parse(d) end |
#to_hash(keys = nil) ⇒ Object Also known as: to_h
21 22 23 24 25 26 27 28 |
# File 'lib/blackbaud-client/api/blackbaud_object.rb', line 21 def to_hash(keys=nil) ivs = (keys ? (instance_variables & keys) : instance_variables) ivs -= [:@client] Hash[* ivs.map { |v| [v.to_s[1..-1].to_sym, instance_variable_get(v)] }.flatten] end |
#to_json(*args) ⇒ Object
30 31 32 |
# File 'lib/blackbaud-client/api/blackbaud_object.rb', line 30 def to_json(*args) JSON.generate(to_hash) end |