Module: Ahub::APIResource

Extended by:
ActiveSupport::Concern
Included in:
Action, Answer, Group, Question, Space, Topic, User
Defined in:
lib/ahub/modules/api_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



9
10
11
# File 'lib/ahub/modules/api_resource.rb', line 9

def attributes
  @attributes
end

Instance Method Details

#initialize(attrs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ahub/modules/api_resource.rb', line 15

def initialize(attrs)
  @attributes = attrs
  attrs.each_pair do |k,v|
    attribute_name = k.to_s.underscore

    if instance_variable_get("@#{attribute_name}").nil?
      instance_variable_set("@#{attribute_name}", v)
    end

    next if respond_to?(k) && k != :id

    self.class.send(:define_method, attribute_name) do
      instance_variable_get("@#{__method__}")
    end
  end
end

#updateObject

Raises:

  • (NotImplementedError)


11
12
13
# File 'lib/ahub/modules/api_resource.rb', line 11

def update
  raise NotImplementedError
end