Class: RBlade::CompilesStatements::CompilesForm
- Inherits:
-
Object
- Object
- RBlade::CompilesStatements::CompilesForm
- Defined in:
- lib/rblade/compiler/statements/compiles_form.rb
Instance Method Summary collapse
- #compileDelete(args) ⇒ Object
- #compileMethod(args) ⇒ Object
- #compileOld(args) ⇒ Object
- #compilePatch(args) ⇒ Object
- #compilePut(args) ⇒ Object
Instance Method Details
#compileDelete(args) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 13 def compileDelete args unless args.nil? raise StandardError.new "Delete statement: wrong number of arguments (given #{args.count}, expecting 0)" end compileMethod(["DELETE"]) end |
#compileMethod(args) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 4 def compileMethod args if args&.count != 1 raise StandardError.new "Method statement: wrong number of arguments (given #{args&.count || 0}, expecting 1)" end method = RBlade.h(args[0].tr("\"'", "")) %(_out<<'<input type="hidden" name="_method" value="#{method}">';) end |
#compileOld(args) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 37 def compileOld args if args.nil? || args.count > 2 raise StandardError.new "Old statement: wrong number of arguments (given #{args&.count || 0}, expecting 1 or 2)" end default_value = args[1] || "''" "_out<<params.fetch(#{args[0]},#{default_value});" end |
#compilePatch(args) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 21 def compilePatch args unless args.nil? raise StandardError.new "Patch statement: wrong number of arguments (given #{args.count}, expecting 0)" end compileMethod(["PATCH"]) end |
#compilePut(args) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rblade/compiler/statements/compiles_form.rb', line 29 def compilePut args unless args.nil? raise StandardError.new "Put statement: wrong number of arguments (given #{args.count}, expecting 0)" end compileMethod(["PUT"]) end |