module FsApi::Resource

Attributes

attributes[R]
errors[RW]

Public Class Methods

new(attributes) click to toggle source
# File lib/fs_api/resource/resource.rb, line 6
def initialize(attributes)
  self.attributes = attributes
end

Public Instance Methods

attributes=(attributes) click to toggle source
# File lib/fs_api/resource/resource.rb, line 10
def attributes=(attributes)
  @attributes = attributes
  attributes.each do |attribute, value|
    if respond_to?(writer = attribute.to_s + '=')
      send(writer, value)
    else
      raise "#{self.class} does not have an `#{attribute}' attribute"
    end
  end
end
from_api=(from_api) click to toggle source

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

# File lib/fs_api/resource/resource.rb, line 46
def from_api=(from_api)
  @from_api = from_api
end
persisted?() click to toggle source
# File lib/fs_api/resource/resource.rb, line 50
def persisted?
  @from_api == true
end
to_json() click to toggle source
# File lib/fs_api/resource/resource.rb, line 36
def to_json
  JSON.generate(attributes)
end
updateable?() click to toggle source
# File lib/fs_api/resource/resource.rb, line 40
def updateable?
  true
end