Class: RecordFormatter::Base
- Inherits:
-
Object
- Object
- RecordFormatter::Base
- Defined in:
- lib/record_formatter/base.rb
Constant Summary collapse
- DEFAULT_SCOPE =
:all
- VALID_OPTIONS =
%i(scope)
Instance Method Summary collapse
- #columns(*attributes) ⇒ Object
- #deployable_records ⇒ Object
-
#initialize(klass, options = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(klass, options = {}) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 |
# File 'lib/record_formatter/base.rb', line 10 def initialize klass, ={} @klass = klass @models = {} @options = .slice!(VALID_OPTIONS) end |
Instance Method Details
#columns(*attributes) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/record_formatter/base.rb', line 16 def columns *attributes defaults = attributes. attributes.each do |name| model.add_column name, defaults end end |
#deployable_records ⇒ Object
24 25 26 |
# File 'lib/record_formatter/base.rb', line 24 def deployable_records @klass.select(columns_for_select).send(defined_scope) end |