Class: Buttons::Button
- Inherits:
-
Object
- Object
- Buttons::Button
- Defined in:
- lib/buttons/button.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
- .argument_list ⇒ Object
- .get(*names) ⇒ Object
- .inherited(base) ⇒ Object
- .js_functions ⇒ Object
- .method_added(name) ⇒ Object
- .namespace ⇒ Object
- .post(*names) ⇒ Object
- .routes ⇒ Object
- .to_js ⇒ Object
Instance Method Summary collapse
- #call_method(method_name) ⇒ Object
-
#initialize(request) ⇒ Button
constructor
A new instance of Button.
- #to_js ⇒ Object
Constructor Details
#initialize(request) ⇒ Button
Returns a new instance of Button.
7 8 9 |
# File 'lib/buttons/button.rb', line 7 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
5 6 7 |
# File 'lib/buttons/button.rb', line 5 def request @request end |
Class Method Details
.argument_list ⇒ Object
41 42 43 |
# File 'lib/buttons/button.rb', line 41 def argument_list @argument_list ||= {} end |
.get(*names) ⇒ Object
49 50 51 52 53 |
# File 'lib/buttons/button.rb', line 49 def get(*names) names.each do |name| add_route(:get, name) end end |
.inherited(base) ⇒ Object
20 21 22 23 |
# File 'lib/buttons/button.rb', line 20 def inherited(base) Buttons.app.add_route(:get, "/#{base.namespace}.js", :button => base, :method => :to_js) end |
.js_functions ⇒ Object
37 38 39 |
# File 'lib/buttons/button.rb', line 37 def js_functions @js_functions ||= [] end |
.method_added(name) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/buttons/button.rb', line 25 def method_added(name) routes.each do |http_method, methods| if methods.include?(name) setup_route(http_method, instance_method(name)) end end end |
.namespace ⇒ Object
33 34 35 |
# File 'lib/buttons/button.rb', line 33 def namespace self.to_s. end |
.post(*names) ⇒ Object
55 56 57 58 59 |
# File 'lib/buttons/button.rb', line 55 def post(*names) names.each do |name| add_route(:post, name) end end |
.routes ⇒ Object
45 46 47 |
# File 'lib/buttons/button.rb', line 45 def routes @routes ||= { } end |
.to_js ⇒ Object
61 62 63 |
# File 'lib/buttons/button.rb', line 61 def to_js Buttons::Javascript::JsGenerator.new(self).to_js end |
Instance Method Details
#call_method(method_name) ⇒ Object
15 16 17 |
# File 'lib/buttons/button.rb', line 15 def call_method(method_name) send(method_name, *create_method_args(method_name)) end |
#to_js ⇒ Object
11 12 13 |
# File 'lib/buttons/button.rb', line 11 def to_js self.class.to_js end |