Openobject-0.0.1

NAME

openobject

SYNOPSIS

a simple property based container that’s much more capable than a
blankslate
but far less polluted than ruby’s built-in OpenStruct. openobject
is a tiny
lib that couples the power of the ‘attributes’ gem alongside a
slightly
enhanced blankslate type object.

INSTALL

gem install openobject

URIS

http://codeforpeople.com/lib/ruby/
http://rubyforge.org/projects/codeforpeople/

SAMPLES

<========< sample/a.rb >========>

~ > cat sample/a.rb

 require 'openobject'

 oo = openobject

 oo.foo = 42
 oo.bar 'forty-two'

 p oo.foo
 p oo.bar

~ > ruby sample/a.rb

 42
 "forty-two"

<========< sample/b.rb >========>

~ > cat sample/b.rb

 require 'openobject'

 oo = openobject :foo => 42, :bar => 'forty-two' do
   foobar 42.0
 end

 p oo.to_hash
 p oo.attributes

~ > ruby sample/b.rb

 {"foobar"=>42.0, "foo"=>42, "bar"=>"forty-two"}
 ["foo", "bar", "foobar"]

<========< sample/c.rb >========>

~ > cat sample/c.rb

 require 'openobject'

 oo = openobject :foo => 42

 oo.bar = 'forty-two'

 oo.extend do
   attribute :foobar => 42.0

   def barfoo
     [ foo, bar, foobar ]
   end
 end

 p oo.foobar
 p oo.barfoo

~ > ruby sample/c.rb

 42.0
 [42, "forty-two", 42.0]

<========< sample/d.rb >========>

~ > cat sample/d.rb

 require 'openobject'

 config =
   openobject do
     attribute :header => openobject(:width => 42, :height => 42)
     attribute :body => openobject(:width => 4242, :height => 4242)
     attribute :footer => openobject(:width => 42.0, :height =>

42.0)
end

 p config.header.width
 p config.footer.height

~ > ruby sample/d.rb

 42
 42.0

AUTHOR

[email protected]

enjoy.

a @ http://drawohara.com/

On Sep 9, 11:04 am, “ara.t.howard” [email protected] wrote:

lib that couples the power of the ‘attributes’ gem alongside a
slightly
enhanced blankslate type object.

Hey dude, the name OpenObject is straight from Facets. And except for
your special attribute DSL, is similar in function.

http://facets.rubyforge.org/rdoc/OpenObjects/index.html

Not a major issue, of course, but certainly can’t hurt to avoid name
conflicts. Care to change the name?

T.

On Sep 9, 2007, at 12:43 PM, Trans wrote:

Not a major issue, of course, but certainly can’t hurt to avoid name
conflicts. Care to change the name?

T.

suggestions?

a @ http://drawohara.com/

On 9/9/07, ara.t.howard [email protected] wrote:

suggestions?
Merge the two projects! :wink:

On Sep 9, 2007, at 1:38 PM, Logan C. wrote:

Merge the two projects! :wink:

they are actually quite a bit different - otherwise not a bad idea.
in particular mine is geared toward open behaviour (methods) not only
properties. still - might be possible…

a @ http://drawohara.com/

From: ara.t.howard [mailto:[email protected]]

config = openobject do

attribute :header => openobject(:width => 42, :height => 42)

attribute :body => openobject(:width => 4242, :height =>

attribute :footer => openobject(:width => 42.0, :height =>

42.0)

end

p config.header.width

p config.footer.height

~ > ruby sample/d.rb

42

42.0

LOL. cool :slight_smile: downloading now…
thanks for openobject… nice name too.
kind regards -botp

On 9/11/07, Steven L. [email protected] wrote:

calibre-openobject (1.0.0)
OpenObject is an improved variation of OpenStruct

openobject (1.3.0)
OpenObject is an improved variation of OpenStruct

In retrospect I’m surprised there aren’t more.

Trans [email protected] writes:

is a tiny
conflicts. Care to change the name?

T.

For that matter, there are at least two others?

% gem search openobject

*** LOCAL GEMS ***

*** REMOTE GEMS ***
Need to update 27 gems from http://gems.rubyforge.org

complete

calibre-openobject (1.0.0)
OpenObject is an improved variation of OpenStruct

openobject (1.3.0)
OpenObject is an improved variation of OpenStruct

Steve

Care to change the name?

Brainstorming! Sorry, I have to add #comments :slight_smile:

How about this:

FreeStruct # hehe
BetterStruct # yay! good indication!

protoobject # original yeah? :smiley:
proteusobject # for a change, why only proto, why not proteus…

libreobject # i dont like that one, but who cares!
objectfate # this object starts blank, but it will grow slowly to
accept its fate in the world!

PS: I think a small problem with facets is that it looks big and
intimidating (to me, I have installed facets but didnt really
dig into it). Such smaller projects as this one are nice to have!

On Sep 11, 5:15 pm, Steven L. [email protected] wrote:

but far less polluted than ruby’s built-in OpenStruct. openobject
Not a major issue, of course, but certainly can’t hurt to avoid name
*** REMOTE GEMS ***
Need to update 27 gems fromhttp://gems.rubyforge.org

complete

calibre-openobject (1.0.0)
OpenObject is an improved variation of OpenStruct

openobject (1.3.0)
OpenObject is an improved variation of OpenStruct

calibre-openobject is an older version of openobject. All the calibre-

  • gems will be deleted soon actually, as that library was was merged
    into Facets a while ago. The openobject gem is a stand-alone release
    of the Facets library. I’ve long debated if I should release parts of
    Facets in small individual packages. I’ve tested the waters in that
    regard with a few libraries like this one. If there’s enough demand, I
    may continue to do so, but in the mean time my focus has been on
    tightening up the the single package.

T.

On Sep 9, 12:52 pm, “ara.t.howard” [email protected] wrote:

On Sep 9, 2007, at 1:38 PM, Logan C. wrote:

Merge the two projects! :wink:

they are actually quite a bit different - otherwise not a bad idea.
in particular mine is geared toward open behaviour (methods) not only
properties. still - might be possible…

I don’t see a great deal of difference between Ara’s openobject and
just using his attribute library with OpenStruct (perhaps with an
extra extension or two). OTOH, Facets’ OpenObject class is designed to
be better than OpenStruct in some ways. It’s faster, more open, and
doesn’t have issues with #dup and so forth b/c of the use of singleton
methods.

On the surface however, the main item of difference is really the
#attribute method. Certainly Facets could incorporate that
functionality, but it sort of goes against the grain of it’s
annotations system, which allows any piece of information to be
attached to attributes, not just default values. For example, Ara’s
lib does:

attribute :x => 10

Where Facets’ would do:

attr_accessor :x, :default => 10

At the moment Facets’ annotations library doesn’t do anything with the
annotations. So this is just a syntax distinction, not a functional
one. But I’ve always planned to expand the annotations system to
handle this, and a few other features like casting. It is for this
reason alone that I have never incorporated Ara’s, otherwise excellent
attribute language.

Eventually I will get the annotations system handling it. The trick
has been finding a good way to generalize the procedure so others can
easily add there own “functional significance” to annotations. The key
to this may lie in around advice, actually. We shall see.

T.

On 9/9/07, Bil K. [email protected] wrote:

ara.t.howard wrote:

suggestions?

Aren’t they both namespaced? If so, where’s the collison?

I don’t think google understands ruby namespaces, when I go searching
for “openobject” :wink:

On Sep 9, 2007, at 3:00 PM, Bil K. wrote:

Aren’t they both namespaced? If so, where’s the collison?

who is this ‘namespaced’ you speak of?

:wink:

a @ http://drawohara.com/

ara.t.howard wrote:

suggestions?

Aren’t they both namespaced? If so, where’s the collison?

Later,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs