Class: Resourceful::Model::Xml
- Defined in:
- lib/resourceful/model/xml.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Class Method Summary collapse
- .get(path, params, search, force = false, &block) ⇒ Object
- .get_collection(path, params, search, force = false, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(xml = nil) ⇒ Xml
constructor
A new instance of Xml.
Methods inherited from Base
agent, #attributes, cleanup_name, #data, #destroy, find, get_namespaced_klass, namespaces, #new_record?, #save, #update_attributes
Methods included from AttributeTypes
Constructor Details
#initialize(xml = nil) ⇒ Xml
Returns a new instance of Xml.
33 34 35 36 |
# File 'lib/resourceful/model/xml.rb', line 33 def initialize(xml=nil) raise Resourceful::Exceptions::ModelError, "trying to initialize a Resourceful::Model::Xml model with '#{xml.class.name}' data" unless xml.nil? || xml.kind_of?(Nokogiri::XML::NodeSet) || xml.kind_of?(Nokogiri::XML::Element) @data = xml end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
9 10 11 |
# File 'lib/resourceful/model/xml.rb', line 9 def xml @xml end |
Class Method Details
.get(path, params, search, force = false, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/resourceful/model/xml.rb', line 11 def self.get(path, params, search, force=false, &block) opts = { :format => 'xml', :params => params || {}, :force => force, :on_response => block } data = super(path, opts) new(data.search(search) || data) end |
.get_collection(path, params, search, force = false, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/resourceful/model/xml.rb', line 21 def self.get_collection(path, params, search, force=false, &block) opts = { :format => 'xml', :params => params || {}, :force => force, :on_response => block } super(path, opts) do |data| data.search(search) || data end end |