Module: Transcriber::Resource::Response
- Extended by:
- ActiveSupport::Concern
- Included in:
- Transcriber::Resource, Embeddable, Property
- Defined in:
- lib/transcriber/resource/response.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #link ⇒ Object
- #resource(options = {}) ⇒ Object
- #resource_keys(options) ⇒ Object
- #summarize?(options) ⇒ Boolean
Instance Method Details
#link ⇒ Object
20 21 22 |
# File 'lib/transcriber/resource/response.rb', line 20 def link self.class.relations.map {|key| key.to_relation(self)} end |
#resource(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/transcriber/resource/response.rb', line 6 def resource( = {}) root = .fetch(:root, true) {}.tap do |resource| resource_keys().inject(resource) do |buffer, key| buffer.merge!(key.to_resource(self)) end if root and self.class.relations.any? and ![:summarize] resource.merge!({link: link}) end end end |
#resource_keys(options) ⇒ Object
24 25 26 27 |
# File 'lib/transcriber/resource/response.rb', line 24 def resource_keys() summarize?() ? self.class.summarized_keys + [Resource::Href.new] : self.class.keys end |
#summarize?(options) ⇒ Boolean
29 30 31 |
# File 'lib/transcriber/resource/response.rb', line 29 def summarize?() [:summarize] and self.class.summarized_keys.any? end |