Class: ActiveSet
- Inherits:
-
Object
- Object
- ActiveSet
- Includes:
- Enumerable
- Defined in:
- lib/active_set.rb,
lib/active_set/sorting/operation.rb,
lib/active_set/column_instruction.rb,
lib/active_set/exporting/operation.rb,
lib/active_set/filtering/operation.rb,
lib/active_set/paginating/operation.rb,
lib/active_set/attribute_instruction.rb,
lib/active_set/exporting/csv_strategy.rb,
lib/active_set/sorting/enumerable_strategy.rb,
lib/active_set/filtering/enumerable_strategy.rb,
lib/active_set/paginating/enumerable_strategy.rb,
lib/active_set/sorting/active_record_strategy.rb,
lib/active_set/filtering/active_record_strategy.rb,
lib/active_set/paginating/active_record_strategy.rb
Defined Under Namespace
Modules: Exporting, Filtering, Paginating, Sorting Classes: AttributeInstruction, ColumnInstruction
Instance Attribute Summary collapse
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#set ⇒ Object
readonly
Returns the value of attribute set.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each(&block) ⇒ Object
- #export(instructions_hash) ⇒ Object
-
#filter(instructions_hash) ⇒ Object
:nocov:.
-
#initialize(set, view: nil, instructions: {}) ⇒ ActiveSet
constructor
A new instance of ActiveSet.
-
#inspect ⇒ Object
:nocov:.
- #method_missing(method_name, *args, &block) ⇒ Object
- #paginate(instructions_hash) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
- #sort(instructions_hash) ⇒ Object
Constructor Details
#initialize(set, view: nil, instructions: {}) ⇒ ActiveSet
Returns a new instance of ActiveSet.
17 18 19 20 21 |
# File 'lib/active_set.rb', line 17 def initialize(set, view: nil, instructions: {}) @set = set @view = view || set @instructions = instructions end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
38 39 40 41 42 |
# File 'lib/active_set.rb', line 38 def method_missing(method_name, *args, &block) return @view.send(method_name, *args, &block) if @view.respond_to?(method_name) super end |
Instance Attribute Details
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
15 16 17 |
# File 'lib/active_set.rb', line 15 def instructions @instructions end |
#set ⇒ Object (readonly)
Returns the value of attribute set.
15 16 17 |
# File 'lib/active_set.rb', line 15 def set @set end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
15 16 17 |
# File 'lib/active_set.rb', line 15 def view @view end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 35 36 |
# File 'lib/active_set.rb', line 32 def ==(other) return @view == other unless other.is_a?(ActiveSet) @view == other.view end |
#each(&block) ⇒ Object
23 24 25 |
# File 'lib/active_set.rb', line 23 def each(&block) @view.each(&block) end |
#export(instructions_hash) ⇒ Object
64 65 66 67 |
# File 'lib/active_set.rb', line 64 def export(instructions_hash) exporter = Exporting::Operation.new(@view, instructions_hash) exporter.execute end |
#filter(instructions_hash) ⇒ Object
:nocov:
49 50 51 52 |
# File 'lib/active_set.rb', line 49 def filter(instructions_hash) filterer = Filtering::Operation.new(@view, instructions_hash) reinitialize(filterer.execute, :filter, filterer.operation_instructions) end |
#inspect ⇒ Object
:nocov:
28 29 30 |
# File 'lib/active_set.rb', line 28 def inspect "#<ActiveSet:#{object_id} @instructions=#{@instructions.inspect}>" end |
#paginate(instructions_hash) ⇒ Object
59 60 61 62 |
# File 'lib/active_set.rb', line 59 def paginate(instructions_hash) paginater = Paginating::Operation.new(@view, instructions_hash) reinitialize(paginater.execute, :paginate, paginater.operation_instructions) end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
44 45 46 |
# File 'lib/active_set.rb', line 44 def respond_to_missing?(method_name, include_private = false) @view.respond_to?(method_name) || super end |