summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2011-11-27 21:53:25 +0900
committerRandy Morgan <[email protected]>2011-11-27 21:53:25 +0900
commitf050dd81a633c45e3c8a57dffcdb4db715183e3d (patch)
tree995191ef952e91198b77283e1ab89a9ac22421dd /lib
parentcdfc7251bde8347678d355e5fe65fc20e120bc23 (diff)
downloadcaxlsx-f050dd81a633c45e3c8a57dffcdb4db715183e3d.tar.gz
caxlsx-f050dd81a633c45e3c8a57dffcdb4db715183e3d.zip
more documentation for 10a release
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/ar.rb16
-rw-r--r--lib/axlsx/workbook/worksheet/row.rb3
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/axlsx/ar.rb b/lib/axlsx/ar.rb
index 2864c95a..83fc7041 100644
--- a/lib/axlsx/ar.rb
+++ b/lib/axlsx/ar.rb
@@ -1,24 +1,33 @@
# ActsAsAxlsx
require 'axlsx'
module Axlsx
-
+ # Mixing module for adding acts_as_axlsx to active record base
module Ar
+ # Extents active record with this ojbects class method acts_as_axlsx
def self.included(base)
base.send :extend, ClassMethods
end
+ # Class methods for the mixin
module ClassMethods
- # we should do what ruport did and use only, exclude and methods hashes
+ # adds in the instance and singleton methods
def acts_as_axlsx(options={})
include Axlsx::Ar::InstanceMethods
extend Axlsx::Ar::SingletonMethods
end
end
+ # Singleton methods for the mixin
module SingletonMethods
+ # Maps the AR class to an Axlsx package
+ # options are passed into AR find
+ # @option options [Integer] header_style to apply to the first row of field names
+ # @option options [Array, Symbol] an array of Axlsx types for each cell in data rows or a single type that will be applied to all types.
+ # @option options [Integer, Array] style The style to pass to Worksheet#add_row
+ # @see Worksheet#add_row
def to_xlsx(number = :all, options = {})
row_style = options.delete(:style)
header_style = options.delete(:header_style) || row_style
@@ -43,6 +52,8 @@ module Axlsx
end
+ # Empty module - I really like ruports way of allowing :include, :only, :exclude
+ # and am looking to add something like that in later
module InstanceMethods
end
@@ -51,6 +62,7 @@ module Axlsx
end
begin
+
require 'active_record'
ActiveRecord::Base.send :include, Axlsx::Ar
rescue Exception=>e
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb
index 0e5333b9..7958124f 100644
--- a/lib/axlsx/workbook/worksheet/row.rb
+++ b/lib/axlsx/workbook/worksheet/row.rb
@@ -62,6 +62,9 @@ module Axlsx
end
end
+ # returns the cells in this row as an array
+ # This lets us transpose the rows into columns
+ # @return [Array]
def to_ary
@cells.to_ary
end