Class: TrustyCms::ResourceResponses::Response
- Inherits:
-
Object
- Object
- TrustyCms::ResourceResponses::Response
show all
- Defined in:
- lib/trusty_cms/resource_responses.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
67
68
69
70
71
|
# File 'lib/trusty_cms/resource_responses.rb', line 67
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
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/trusty_cms/resource_responses.rb', line 109
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
Returns the value of attribute block_order.
66
67
68
|
# File 'lib/trusty_cms/resource_responses.rb', line 66
def block_order
@block_order
end
|
#blocks ⇒ Object
Returns the value of attribute blocks.
66
67
68
|
# File 'lib/trusty_cms/resource_responses.rb', line 66
def blocks
@blocks
end
|
#publish_block ⇒ Object
Returns the value of attribute publish_block.
66
67
68
|
# File 'lib/trusty_cms/resource_responses.rb', line 66
def publish_block
@publish_block
end
|
Returns the value of attribute publish_formats.
66
67
68
|
# File 'lib/trusty_cms/resource_responses.rb', line 66
def publish_formats
@publish_formats
end
|
Instance Method Details
#default(&block) ⇒ Object
81
82
83
84
85
86
|
# File 'lib/trusty_cms/resource_responses.rb', line 81
def default(&block)
if block_given?
@default = block
end
@default
end
|
103
104
105
106
107
|
# File 'lib/trusty_cms/resource_responses.rb', line 103
def each_format
@block_order.each do |format|
yield format, @blocks[format] if block_given?
end
end
|
#each_published ⇒ Object
97
98
99
100
101
|
# File 'lib/trusty_cms/resource_responses.rb', line 97
def each_published
publish_formats.each do |format|
yield format, publish_block if block_given?
end
end
|
#initialize_copy(orig) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/trusty_cms/resource_responses.rb', line 73
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
88
89
90
91
92
93
94
95
|
# File 'lib/trusty_cms/resource_responses.rb', line 88
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
|