Skip to content

Commit

Permalink
Minor documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed Jul 8, 2011
1 parent c1cb306 commit e4cea92
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lib/virtus/attribute.rb
Expand Up @@ -249,6 +249,8 @@ def self.primitive?(value)
# @param [#to_hash] options
# hash of extra options which overrides defaults set on an attribute class
#
# @return [undefined]
#
# @api private
def initialize(name, options = {})
@name = name
Expand Down Expand Up @@ -292,6 +294,8 @@ def typecast(value)

# Converts the given value to the primitive type
#
# @return [Object]
#
# @api private
def typecast_to_primitive(value)
value
Expand Down
2 changes: 2 additions & 0 deletions lib/virtus/attribute/date_time.rb
Expand Up @@ -26,6 +26,8 @@ class DateTime < Object

# @see Virtus::Typecast::Time.to_datetime
#
# @return [DateTime]
#
# @api private
def typecast_to_primitive(value)
Typecast::Time.to_datetime(value)
Expand Down
2 changes: 2 additions & 0 deletions lib/virtus/attribute/decimal.rb
Expand Up @@ -16,6 +16,8 @@ class Decimal < Numeric

# @see Virtus::Typecast::Numeric.to_d
#
# @return [BigDecimal]
#
# @api private
def typecast_to_primitive(value)
Typecast::Numeric.to_d(value)
Expand Down
2 changes: 2 additions & 0 deletions lib/virtus/attribute/float.rb
Expand Up @@ -25,6 +25,8 @@ class Float < Numeric

# @see Virtus::Typecast::Numeric.to_f
#
# @return [Float]
#
# @api private
def typecast_to_primitive(value)
Typecast::Numeric.to_f(value)
Expand Down
2 changes: 2 additions & 0 deletions lib/virtus/attribute/integer.rb
Expand Up @@ -22,6 +22,8 @@ class Integer < Numeric

# @see Virtus::Typecast::Numeric.to_i
#
# @return [Integer]
#
# @api private
def typecast_to_primitive(value)
Typecast::Numeric.to_i(value)
Expand Down
2 changes: 2 additions & 0 deletions lib/virtus/attribute/string.rb
Expand Up @@ -19,6 +19,8 @@ class String < Object

# @see Virtus::Typecast::String.call
#
# @return [String]
#
# @api private
def typecast_to_primitive(value)
Virtus::Typecast::String.call(value)
Expand Down
9 changes: 8 additions & 1 deletion lib/virtus/attribute/time.rb
Expand Up @@ -16,7 +16,12 @@ class Attribute
#
# # typecasting from a hash
# Post.new(:published_at => {
# :year => 2011, :month => 6, :day => 9, :hour => 11, :minutes => 8 })
# :year => 2011,
# :month => 6,
# :day => 9,
# :hour => 11,
# :minutes => 8
# })
#
# # typecasting from an object which implements #to_time
# Post.new(:published_at => DateTime.now)
Expand All @@ -26,6 +31,8 @@ class Time < Object

# @see Virtus::Typecast::Time.to_time
#
# @return [Time]
#
# @api private
def typecast_to_primitive(value)
Typecast::Time.to_time(value)
Expand Down
5 changes: 2 additions & 3 deletions lib/virtus/class_methods.rb
Expand Up @@ -49,12 +49,11 @@ def attribute(name, type, options = {})
# attribute :age, Integer
# end
#
# User.attributes # => { name_attribute, age_attribute }
# User.attributes # =>
#
# TODO: implement inspect so the output is not cluttered - solnic
#
# @return [Hash]
# an attributes hash indexed by attribute names
# @return [AttributeSet]
#
# @api public
def attributes
Expand Down
8 changes: 5 additions & 3 deletions lib/virtus/instance_methods.rb
Expand Up @@ -8,7 +8,7 @@ module InstanceMethods
# @param [#to_hash] attributes
# the attributes hash to be set
#
# @return [Object]
# @return [undefined]
#
# @api private
def initialize(attributes = {})
Expand Down Expand Up @@ -79,7 +79,6 @@ def []=(name, value)
# user.attributes # => { :name => 'John', :age => 28 }
#
# @return [Hash]
# the attributes
#
# @api public
def attributes
Expand Down Expand Up @@ -110,7 +109,6 @@ def attributes
# a hash of attribute values to be set on an object
#
# @return [Hash]
# the attributes
#
# @api public
def attributes=(attributes)
Expand All @@ -125,6 +123,8 @@ def attributes=(attributes)
#
# @see Virtus::InstanceMethods#[]
#
# @return [Object]
#
# @api private
def attribute_get(name)
__send__(name)
Expand All @@ -134,6 +134,8 @@ def attribute_get(name)
#
# @see Virtus::InstanceMethods#[]=
#
# @return [Object]
#
# @api private
def attribute_set(name, value)
__send__("#{name}=", value)
Expand Down
6 changes: 3 additions & 3 deletions lib/virtus/typecast/time.rb
Expand Up @@ -19,7 +19,7 @@ class Time
# Virtus::Typecast::Time.to_time('2011/06/09 12:01')
# # => Thu Jun 09 12:01:00 +0200 2011
#
# @param [Hash, #to_mash, #to_s] value
# @param [#to_hash, #to_s] value
# value to be typecast
#
# @return [Time]
Expand All @@ -38,7 +38,7 @@ def self.to_time(value)
# Virtus::Typecast::Time.to_date('2011/06/09')
# # => #<Date: 4911443/2,0,2299161>
#
# @param [Hash, #to_mash, #to_s] value
# @param [#to_hash, #to_s] value
# value to be typecast
#
# @return [Date]
Expand All @@ -57,7 +57,7 @@ def self.to_date(value)
# Virtus::Typecast::Time.to_datetime('2011/06/09 12:01')
# # => #<DateTime: 3536239681/1440,0,2299161>
#
# @param [Hash, #to_mash, #to_s] value
# @param [#to_hash, #to_s] value
# value to be typecast
#
# @return [DateTime]
Expand Down

0 comments on commit e4cea92

Please sign in to comment.