Class: Rose::ObjectAdapter

Inherits:
Object
  • Object
show all
Extended by:
CoreExtensions
Defined in:
lib/rose/object.rb

Overview

This class is provides Objects the ability to run reports

Direct Known Subclasses

ActiveRecordAdapter

Class Method Summary collapse

Methods included from CoreExtensions

require_keys, required_values

Class Method Details

.osmosis(seedling, options = {}) ⇒ Object

Parameters:

  • seedling (Rose::Seedling)

    the seedling to update

  • options (Hash) (defaults to: {})

    the options to run with

Options Hash (options):

  • :items (Array) — default: required

    an Array of items

  • :with (Hash, String) — default: required

    (see Rose::Shell#photosynthesize)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rose/object.rb', line 42

def self.osmosis(seedling, options={})
  hash_or_csv, items = required_values(options, :with, :items)

  root, row = seedling.root, seedling.row
  idy_attr = row.identity_attribute

  items = case hash_or_csv
  when String # CSV File
    self.osmosis_from_csv(root, options.merge(
      :idy_attr => idy_attr,
      :csv_file => hash_or_csv,
      :items    => items
    ))
  when Hash
    self.osmosis_from_hash(root, options.merge(
      :idy_attr => idy_attr,
      :updates  => hash_or_csv,
      :items    => items
    ))
  end

  self.sprout(seedling, options.merge(
    :attributes => row.attributes,
    :items      => items
  ))
end

.sprout(seedling, options = {}) ⇒ Ruport::Data::Table

Returns the resulting table.

Parameters:

  • seedling (Rose::Seedling)

    the seedling to sprout

  • options (Hash) (defaults to: {})

    the options to run with

Options Hash (options):

  • :items (Array) — default: required

    the items to report on

  • :attributes (Rose::Attribute::Collection) — default: nil

    a row of attributes

  • :group_column (String) — default: nil

    @deprecated

  • :pivot_column (String) — default: nil

    @deprecated

  • :value_block (String) — default: nil

    @deprecated

  • :summary (String) — default: nil

    @deprecated

  • :summary_on (String) — default: nil

    @deprecated

  • :sort_by (String) — default: nil

    @deprecated

  • :sort_order (String) — default: nil

    @deprecated

Returns:

  • (Ruport::Data::Table)

    the resulting table



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rose/object.rb', line 23

def self.sprout(seedling, options={})
  items, attributes = required_values(options, :items, :attributes)
  table = Ruport::Data::RoseTable.new(:column_names => attributes.column_names)

  self.rows(table, options)

  if (alterations = options[:alterations])
    alterations.each do |alteration|
      table = alteration.on(table)
    end
  end

  table
end