Class: MC2P::ObjectItemMixin
- Inherits:
-
Object
- Object
- MC2P::ObjectItemMixin
- Defined in:
- lib/mixins.rb
Overview
Basic info of the object item
Direct Known Subclasses
CardShareObjectItemMixin, ChargeObjectItemMixin, CreateObjectItemMixin, DeleteObjectItemMixin, ObjectItem, PayURLMixin, RefundCaptureVoidObjectItemMixin, RetrieveObjectItemMixin
Instance Attribute Summary collapse
-
#_deleted ⇒ Object
Returns the value of attribute _deleted.
-
#json_dict ⇒ Object
Returns the value of attribute json_dict.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #id_required_and_not_deleted ⇒ Object
-
#initialize(json_dict, resource, id_property = 'id') ⇒ ObjectItemMixin
constructor
A new instance of ObjectItemMixin.
-
#to_s ⇒ Object
Returns: Name of the object and content.
Constructor Details
#initialize(json_dict, resource, id_property = 'id') ⇒ ObjectItemMixin
Returns a new instance of ObjectItemMixin.
9 10 11 12 13 14 |
# File 'lib/mixins.rb', line 9 def initialize(json_dict, resource, id_property = 'id') @json_dict = json_dict @resource = resource @_deleted = nil @id_property = id_property end |
Instance Attribute Details
#_deleted ⇒ Object
Returns the value of attribute _deleted.
7 8 9 |
# File 'lib/mixins.rb', line 7 def _deleted @_deleted end |
#json_dict ⇒ Object
Returns the value of attribute json_dict.
5 6 7 |
# File 'lib/mixins.rb', line 5 def json_dict @json_dict end |
#resource ⇒ Object
Returns the value of attribute resource.
6 7 8 |
# File 'lib/mixins.rb', line 6 def resource @resource end |
Instance Method Details
#id_required_and_not_deleted ⇒ Object
16 17 18 19 20 |
# File 'lib/mixins.rb', line 16 def id_required_and_not_deleted raise BadUseError('Object don\'t have ID') unless @json_dict.fetch(@id_property, false) raise BadUseError('Object deleted') if @_deleted end |
#to_s ⇒ Object
Returns: Name of the object and content
23 24 25 |
# File 'lib/mixins.rb', line 23 def to_s "#{self.class.name} #{@json_dict}" end |