Module: Finix::HalResource

Included in:
Pagination, Resource
Defined in:
lib/finix/hal_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/finix/hal_resource.rb', line 7

def method_missing(method, *args, &block)
  if @attributes.has_key?(method.to_s)
    return @attributes[method.to_s]
  end

  case method.to_s
    when /(.+)=$/
      attr = method.to_s.chop
      @attributes[attr] = args[0]
    else
      if @hyperlinks.has_key? "#{method}"
        value = @hyperlinks["#{method}"]
        result = value.call
        return result
      end
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/finix/hal_resource.rb', line 5

def attributes
  @attributes
end

Returns the value of attribute hyperlinks.



4
5
6
# File 'lib/finix/hal_resource.rb', line 4

def hyperlinks
  @hyperlinks
end