Class: Roar::Rails::ControllerAdditions::RepresenterComputer
- Inherits:
-
Hash
- Object
- Hash
- Roar::Rails::ControllerAdditions::RepresenterComputer
- Defined in:
- lib/roar/rails/controller_additions.rb
Defined Under Namespace
Classes: Path
Instance Method Summary collapse
Instance Method Details
#add(format, opts) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/roar/rails/controller_additions.rb', line 69 def add(format, opts) # FIXME: use controller_path here as well! # by pre-computing the representer name we allow "one-step inheritance": if B doesn't call ::represents it "inherits" A's settings. unless opts.is_a?(Hash) model_name = opts.name.underscore opts = { :entity => add_representer_suffix(model_name), :collection => add_representer_suffix(model_name.pluralize) } end self[format] = opts end |
#for(*args) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/roar/rails/controller_additions.rb', line 83 def for(*args) name = name_for(*args) or return return name if name.is_a?(Module) # i hate is_a? but this is really handy here. name.camelize.constantize end |