Class: ClassyResources::ResourceBuilder
- Inherits:
-
Object
- Object
- ClassyResources::ResourceBuilder
- Defined in:
- lib/classy_resources.rb
Instance Attribute Summary collapse
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#main ⇒ Object
readonly
Returns the value of attribute main.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
- #build! ⇒ Object
-
#initialize(main, *args) ⇒ ResourceBuilder
constructor
A new instance of ResourceBuilder.
Constructor Details
#initialize(main, *args) ⇒ ResourceBuilder
Returns a new instance of ResourceBuilder.
39 40 41 42 43 44 45 46 |
# File 'lib/classy_resources.rb', line 39 def initialize(main, *args) @main = main @options = args.pop if args.last.is_a?(Hash) @resources = args @formats = [:formats] || :xml build! end |
Instance Attribute Details
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
37 38 39 |
# File 'lib/classy_resources.rb', line 37 def formats @formats end |
#main ⇒ Object (readonly)
Returns the value of attribute main.
37 38 39 |
# File 'lib/classy_resources.rb', line 37 def main @main end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
37 38 39 |
# File 'lib/classy_resources.rb', line 37 def @options end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
37 38 39 |
# File 'lib/classy_resources.rb', line 37 def resources @resources end |
Instance Method Details
#build! ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/classy_resources.rb', line 48 def build! resources.each do |r| [*formats].each do |f| [:member, :collection].each do |t| [*[t]].each do |v| send(:"define_#{t}_#{v}", r, f) unless v.nil? end end end end end |