Module: ActiveRemote::Publication

Included in:
Base
Defined in:
lib/active_remote/publication.rb

Instance Method Summary collapse

Instance Method Details

#_publishable_json_attributesObject



28
29
30
# File 'lib/active_remote/publication.rb', line 28

def _publishable_json_attributes
  _publishable_attributes_or_attribute_keys - _publishable_json_methods
end

#_publishable_json_methodsObject



32
33
34
# File 'lib/active_remote/publication.rb', line 32

def _publishable_json_methods
  _publishable_attributes_or_attribute_keys.reject { |attribute| @attributes.key?(attribute) }
end

#publishable_hashObject

Returns a hash of publishable attributes.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_remote/publication.rb', line 5

def publishable_hash
  keys = _publishable_attributes_or_attribute_keys

  attributes_hash = keys.inject({}) do |publishable_hash, key|
    value = respond_to?(key) ? __send__(key) : read_attribute(key)

    publishable_hash[key] = case
                            when value.respond_to?(:map) then
                              _map_value(value)
                            when value.respond_to?(:publishable_hash) then
                              value.publishable_hash
                            when value.respond_to?(:to_hash) then
                              value.to_hash
                            else
                              value
                            end

    publishable_hash
  end

  attributes_hash
end