Module: FsApi::Resource

Included in:
Client, Invoice, InvoicesPayment, Product
Defined in:
lib/fs_api/resource/resource.rb

Defined Under Namespace

Modules: ClassMethods Classes: Client, Invoice, InvoicesPayment, Product

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/fs_api/resource/resource.rb', line 3

def attributes
  @attributes
end

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/fs_api/resource/resource.rb', line 4

def errors
  @errors
end

Instance Method Details

#from_api=(from_api) ⇒ Object

Bit of a hack to know whether instances came from the api and know they are persisted



46
47
48
# File 'lib/fs_api/resource/resource.rb', line 46

def from_api=(from_api)
  @from_api = from_api
end

#initialize(attributes) ⇒ Object



6
7
8
# File 'lib/fs_api/resource/resource.rb', line 6

def initialize(attributes)
  self.attributes = attributes
end

#persisted?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/fs_api/resource/resource.rb', line 50

def persisted?
  @from_api == true
end

#to_jsonObject



36
37
38
# File 'lib/fs_api/resource/resource.rb', line 36

def to_json
  JSON.generate(attributes)
end

#updateable?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/fs_api/resource/resource.rb', line 40

def updateable?
  true
end