Class: Teepee::ActionableCommander
Instance Attribute Summary
Attributes inherited from Commander
#parser
Instance Method Summary
collapse
Methods inherited from Commander
#%, #*, #**, #+, #-, #/, #acos, #acosh, #add_percentage, #asin, #asinh, #atan, #atanh, #b, #backquote, #backslash, #big, #bookmarks_folder_id, #boolean_and, #boolean_nand, #boolean_nor, #boolean_not, #boolean_or, #boolean_xnor, #boolean_xor, #br, #case_operator, #ceiling, #command_error, #command_not_yet_implemented, #comment, #cond_operator, #cos, #cosh, #decrement, #define, #degrees2radians, #del, #dollar, #dotimes, #e, #ensure_boolean, #ensure_numeric, #enumerate, #enumerate_lowercase, #enumerate_numeric, #enumerate_roman_lowercase, #enumerate_roman_uppercase, #enumerate_uppercase, #equal, #erf, #erfc, #false_constant, #false_constant?, #floor, #folder_id, #forum_id, #gamma, #get_operator, #greater_than, #greater_than_or_equal, #h1, #h2, #h3, #h4, #h5, #h6, #html_tag, #hypot, #i, #if_operator, #image, #increment, #is_defined?, #it, #item, #itemize, #itemize_circle, #itemize_disc, #itemize_none, #itemize_square, #keyword_id, #ld, #ldexp, #left_brace, #left_bracket, #left_strip, #less_than, #less_than_or_equal, #lgamma, #link, #link_id, #ln, #log, #log10, #mailto, #mod, #nbsp, #non_numeric_error, #not_equal, #note_id, #number_from_word, #numeric?, #percent_total, #pi, #pipe, #pipe?, #prog1_operator, #progn_operator, #prognil, #radians2degrees, #right_brace, #right_bracket, #right_strip, #round, #sin, #sinh, #small, #space, #span_operator, #sqrt, #squiggle, #strip, #sub, #subtract_percentage, #sup, #table, #table_data, #table_header, #table_row, #tag_id, #tan, #tanh, #tb_href, #to_numbers, #true_constant, #true_constant?, #tt, #u, #undefine, #unless_operator, #valid_email_address?, #valid_uri?, #variable_not_defined_error, #when_operator
Constructor Details
49
50
51
52
53
|
# File 'lib/teepee/actionable-commander.rb', line 49
def initialize params
@action_view = params[:action_view]
@controller = params[:controller]
super nil
end
|
Instance Method Details
#id_command_handler(id, klass, singular = klass.to_s.camelcase_to_snakecase, plural = singular.pluralize, partial = "#{plural}/inline", view = "") ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/teepee/actionable-commander.rb', line 55
def id_command_handler(id,
klass,
singular = klass.to_s.camelcase_to_snakecase,
plural = singular.pluralize,
partial = "#{plural}/inline",
view="")
if not id
command_error "#{singular}_id: error: no #{singular} ID specified"
elsif not id.to_s =~ /\A[0-9]+\z/
command_error "#{singular}_id: error: invalid #{singular} ID specified"
else
thing = eval(klass.to_s).find_by_id Integer(id.to_s)
if thing
@action_view.render partial: partial,
locals: {singular.to_sym => thing}
else
command_error "unknown #{singular} ID #{id.to_s}"
end
end
end
|
#user(user) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/teepee/actionable-commander.rb', line 76
def user user
if not user
command_error "user: error: no user specified"
else
the_user = User.smart_find user.to_s
if the_user
@action_view.render partial: 'users/name_link',
locals: {the_user: the_user}
else
command_error "unknown user #{user.to_s}"
end
end
end
|