Class: Admino::Table::Presenter
- Inherits:
-
Showcase::Presenter
- Object
- Showcase::Presenter
- Admino::Table::Presenter
- Defined in:
- lib/admino/table/presenter.rb
Instance Attribute Summary collapse
-
#collection_klass ⇒ Object
readonly
Returns the value of attribute collection_klass.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Presenter
constructor
A new instance of Presenter.
- #to_html(options = {}, &block) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Presenter
Returns a new instance of Presenter.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/admino/table/presenter.rb', line 32 def initialize(*args) context = args.pop collection = args.shift @collection_klass = args.shift if !@collection_klass && !collection.empty? @collection_klass = collection.first.class end @query = args.shift super(collection, context) end |
Instance Attribute Details
#collection_klass ⇒ Object (readonly)
Returns the value of attribute collection_klass.
8 9 10 |
# File 'lib/admino/table/presenter.rb', line 8 def collection_klass @collection_klass end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
9 10 11 |
# File 'lib/admino/table/presenter.rb', line 9 def query @query end |
Class Method Details
.tag_helper(name, tag, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/admino/table/presenter.rb', line 11 def self.tag_helper(name, tag, = {}) = :"#{name}_html_options" define_method :"#{name}_tag" do |*args, &block| = args. if respond_to?(, true) = send(, *args) = Showcase::Helpers::HtmlOptions.new() .merge_attrs!() = .to_h end h.content_tag(tag, , &block) end end |
Instance Method Details
#to_html(options = {}, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/admino/table/presenter.rb', line 47 def to_html( = {}, &block) if @collection_klass.nil? raise ArgumentError, 'collection is empty and no explicit class is specified' end table_tag() do thead_tag do thead_tr_tag do (&block) end end << tbody_tag do (&block) end end end |