Class: Radiant::ResourceResponses::Response
- Defined in:
- lib/radiant/resource_responses.rb
Instance Attribute Summary collapse
-
#block_order ⇒ Object
readonly
Returns the value of attribute block_order.
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#publish_block ⇒ Object
readonly
Returns the value of attribute publish_block.
-
#publish_formats ⇒ Object
readonly
Returns the value of attribute publish_formats.
Instance Method Summary collapse
- #default(&block) ⇒ Object
- #each_format ⇒ Object
- #each_published ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #initialize_copy(orig) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #publish(*formats, &block) ⇒ Object
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
61 62 63 64 65 |
# File 'lib/radiant/resource_responses.rb', line 61 def initialize @publish_formats = [] @blocks = {} @block_order = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/radiant/resource_responses.rb', line 103 def method_missing(method, *args, &block) if block_given? @blocks[method] = block @block_order << method unless @block_order.include?(method) elsif args.empty? @block_order << method else super end end |
Instance Attribute Details
#block_order ⇒ Object (readonly)
Returns the value of attribute block_order.
60 61 62 |
# File 'lib/radiant/resource_responses.rb', line 60 def block_order @block_order end |
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
60 61 62 |
# File 'lib/radiant/resource_responses.rb', line 60 def blocks @blocks end |
#publish_block ⇒ Object (readonly)
Returns the value of attribute publish_block.
60 61 62 |
# File 'lib/radiant/resource_responses.rb', line 60 def publish_block @publish_block end |
#publish_formats ⇒ Object (readonly)
Returns the value of attribute publish_formats.
60 61 62 |
# File 'lib/radiant/resource_responses.rb', line 60 def publish_formats @publish_formats end |
Instance Method Details
#default(&block) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/radiant/resource_responses.rb', line 75 def default(&block) if block_given? @default = block end @default end |
#each_format ⇒ Object
97 98 99 100 101 |
# File 'lib/radiant/resource_responses.rb', line 97 def each_format @block_order.each do |format| yield format, @blocks[format] if block_given? end end |
#each_published ⇒ Object
91 92 93 94 95 |
# File 'lib/radiant/resource_responses.rb', line 91 def each_published publish_formats.each do |format| yield format, publish_block if block_given? end end |
#initialize_copy(orig) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/radiant/resource_responses.rb', line 67 def initialize_copy(orig) @publish_formats = orig.publish_formats.dup @blocks = orig.blocks.dup @block_order = orig.block_order.dup @publish_block = orig.publish_block.dup if orig.publish_block @default = orig.default.dup if orig.default end |
#publish(*formats, &block) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/radiant/resource_responses.rb', line 82 def publish(*formats, &block) @publish_formats.concat(formats) if block_given? @publish_block = block else raise ArgumentError, "Block required to publish" unless @publish_block end end |